JavaScript
$.ajax({
type : 'POST',
url : 'post.php',
data: dataString,
success:function (data) {
if (data==null) { alert("darnit!!!!");}
//$("#response").append(data);
alert(dataString);
}
});
});
in PHP file just a simple
print_r($_REQUEST);
Also tried
echo "got iT!";
But nothing, been looking of over tried differant things but no luck
first //alert (dataString); works
but after the success:function (data) I don’t get any alerts – no response within the page!
What am I doing wrong?
There’s a SyntaxError in your snippet. I’m not sure if that’s also in your real code.
Be sure to use
json_encodein your PHP file anddataType: 'json'in jQuery.ajax. And always use anerrorcallback as well. You don’t want your application to become indefinitely frozen if something fails.Something like this:
PHP: