I have an ajax call in the head section of my index.html
$(function() {
alert("Hello, World!");
$.ajax({
method: 'get',
url : 'php/getRecord.php?color=red',
dataType: "json",
success: function (data) {
alert(data);
}
});
});
For some reason, that alert(data) never gets called but the “Hello, World!” gets called. Am I doing something wrong? The PHP file does give me data when testing it directly.
You’re probably getting an error somewhere.
Check the HTTP request in Firebug or Fiddler and make sure that it’s doing what you expect.
Add an
error:handler and see whether it gets fired.