Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8010479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:44:48+00:00 2026-06-04T18:44:48+00:00

I have a site that is sending off using the .post function in JQuery

  • 0

I have a site that is sending off using the .post function in JQuery to run a php script. This script adds some data to a database but if the data already exists in the database it doesn’t add the data. Depending on whether the data is added or not I want the javascript to do different things. I don’t know how to get the php to return a value that says “data entered” or “data not entered” so the javascript can use that value to decided upon it next action.

Here is the javascript, I only want the append to happen if the php returns that the data was entered into the database.

$('#addpios').click(function() {
  var scopesheetidvalue = $("#scopesheetid").val();
  var piovalue = $("#pioselected").val();
$.post("addpio.php", { scopesheetid: scopesheetidvalue, pionumber: piovalue },function(data){
$('#pioslist').append("<li><input class='removepio' type='submit' value='"+piovalue+"' /><span class='listitem'>PIO "+piovalue+"</span></li>");} 
    );   
}); 

Here is the PHP

$scopesheetid = $_POST['scopesheetid'];
$pionumber = $_POST['pionumber'];
$alreadyexisitssql = "SELECT * FROM [ScopesheetPIO] WHERE [ScopesheetID]='$scopesheetid' AND [PIONumber]='$pionumber'";
$alreadyexisits=odbc_exec($connection,$alreadyexisitssql);

if(odbc_fetch_row($alreadyexisits)){
//retrun a value that says the data already exists
}
else{
    $addpiosql = "INSERT INTO [ScopesheetPIO] ([ScopesheetID], [PIONumber]) VALUES ('$scopesheetid', '$pionumber')";
    $addpioresult=odbc_exec($connection,$addpiosql);
//retrun a vlaue that the data was added
}

What I really want is a way to pass a value from the PHP script back into the Jquery

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T18:44:51+00:00Added an answer on June 4, 2026 at 6:44 pm

    I would modify your jQuery to the following:

    $.post('addpio.php', { ... }, function(data) {
        if (data.result) {
            $('#pioslist').append(...);
        }
    }, 'json');
    

    In your PHP file, use this when the data is inserted:

    echo json_encode(array(
        'result' => TRUE
    ));
    

    Use this when the data already exists:

    echo json_encode(array(
        'result' => FALSE
    ));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a site that I'm building out with php that will allow for
I have a site that that scrapes off of it's sister sites but for
I have a client that is sending XML for my site to parse. I
I have create a script that I like to send some data to another
I have an Html site.In that there have form for sending mail in Each
I have a site that the other week was sending email just fine. All
I have a DLL that provides mail sending functionality to an asp.net application, this
I have implemented search by map function on my web-site. The map have some
We have a site that offers very large files for download to clients. These
I have a site that provides an e-commerce service, basically allowing sellers in the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.