0

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.

1 Answer 1

3

I believe

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

should be

$.get(url,{sheetnum: $("input#sheetnum").val()},verifyDb);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.