html – Sending values with jQuery’s Get function – Education Career Blog

I am currently coding something to check my database to check for duplicate errors. It is a form and I am having the following function check for duplicate values using jQuery.get.

function makeAjaxRequest()
{
   $("label#bad_error").hide();
   $("label#good_error").hide();
   $("label#checkingdb_error").show();

   $.get(url,{sheetnum: '$("input#sheetnum").val()'},verifyDb);
}

function verifyDb(response)
{
    if (response==1)
    {
   $("label#checkingdb_error").hide();
   $("label#bad_error").show();
    }

    else
    {
   $("label#checkingdb_error").hide();
   $("label#good_error").show();
    }
}

I am having it do this onBlur of a text field. My php file is as follows:

<?

$sheetnum = $_GET'sheetnum';

if($sheetnum == "1234"){
echo "1";
}

?>

I used “1234” instead of the mysql string for now, just to test that the javascript side of it is working.

When I type 1234 in the text box it returns that there are no errors (the good_error label). Am I putting the value wrong in the .get string? Please help.

,

I believe

$.get(url,{sheetnum: '$("input#sheetnum").val()'},verifyDb);

should be

$.get(url,{sheetnum: $("input#sheetnum").val()},verifyDb);

Leave a Comment