What should a PHP generate to give back to a jQuery AJAX request?
Posted
by Alex Mcp
on Stack Overflow
See other posts from Stack Overflow
or by Alex Mcp
Published on 2010-03-13T00:46:36Z
Indexed on
2010/03/13
0:47 UTC
Read the original article
Hit count: 361
Perhaps it's a syntax error, but I never assume that. I have a -dead- simple AJAX test set up:
http://www.mcphersonindustries.com/bucket/api.php is a file with simply:
<?php echo "test"; ?>
And I have Apache as localhost with this jQuery bit running:
$(document).ready(function() {
function doAjaxPost() {
$.ajax({
type: "POST",
url: "http://www.mcphersonindustries.com/bucket/api.php",
data: "null",
success: function(resp){
console.log("Response: '" + resp + "'");
},
error: function(e){
console.log('Error: ' + e);
}
});
}
doAjaxPost();
});
So Firebug spits out Response: ''
each time, but nothing's coming through the request. Do I need to declare a header in PHP? Am I making a boneheaded mistake somewhere?
Thanks for the insights, as always.
© Stack Overflow or respective owner