javascript - how to get the value passed by $.post ajax in php file -


my ajax call like,

    var txt=$('#keyword').value;     $.post("ajax.php?for=result", {suggest: "keyword="+txt}, function(result){    $("#search_result").html(result);      }); 

in php file, want value of textbox id 'keyword', passed

var txt=$('#keyword').value; $.post("ajax.php?for=result", {suggest: "keyword="+txt}, 

i tried in php file using $_post , $_get method, gives me error 'undefined index'

how can value in php file?. provide me example of how using json.

you did not post values properly.

the proper way of posting values either plain object

var txt=$('#keyword').value; $.post("ajax.php?for=result", {keyword: txt}, function(result){    $("#search_result").html(result); }); 

or string of key=value seperated '&'

var txt=$('#keyword').value; $.post("ajax.php?for=result", "keyword="+txt, function(result){    $("#search_result").html(result); }); 

Popular posts from this blog