jquery - ajax post with PHP -



jquery - ajax post with PHP -

why isn't working?

jquery ajax code:

$("header input").bind("keyup", function() { var searchstring= $("header input").val(); var datastring = 'search=' + searchstring; alert(datastring); $.ajax({ type: "post", url: "index.php", data: datastring, cache: false }); });

php code(just test code):

if($_post["search"]) { echo "test message!"; }

it doesn't show echo :/

thanks ur help ;)

you need display info receive ajax call. example, set result <div> called yourresultdiv:

try this

$("header input").on("keyup", function () { var searchstring = $("header input").val(); var datastring = 'search=' + searchstring; alert(datastring); $.ajax({ type: "post", url: "index.php", data: datastring, cache: false, success: function (data) { $('#yourresultdiv').html(data); alert("successful"); } }); });

php jquery ajax

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -