What should a PHP generate to give back to a jQuery AJAX request?
- by Alex Mcp
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.