javascript - storing html(response) in var -


im using ajax send form without reloading. use following method this:

my mail sender:

if (filter_var($email, filter_validate_email)) {     mailto($to, $subject, $message, $headers);      echo "0"; }else{     echo "1"; } 

the script sends info php file above

$(document).ready(function(){     $('#submitbtn').click(function(){         $.post("send.php", $("#mycontactform").serialize(),  function(response) {                $('#success').html(response);         });         return false;     }); }); 

whenever give valid email , send returns 0. when fails returns 1. instead of displaying value in div #success want store value in var can see if mail send or not. , if send can hide contact form.

i came this:

$(document).ready(function(){     $('#submitbtn').click(function(){         $.post("send.php", $("#mycontactform").serialize(),  function(response) {                var x = html(response);             if (x == 0){             $('#mycontactform.hide').hide;                 document.getelementbyid('succes').innerhtml = 'message send';             }else{                 //display error message             }         });         return false;     }); }); 

but not working. know why. assume has var x = not storing html response

in first snippet, did this:

$('#success').html(response); 

here, html() function of $, in second snippet did this:

var x = html(response); 

but presumably have no global function called html()? want:

var x = parseint( response,10 ); 

i highly recommend looking using chrome/firefox/ie devtools in order debug stuff in future.


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -