Javascript code, using jQuery 1.7:
$( function() {
$.get('/ajax_dummy', function() { alert('foo'); })
});
With Firebug I can see that the HTTP GET request is sent and a “hello world” response with code 200 is returned, so everything seems fine. But the callback is never called.
I have no idea what is wrong; this should be so simple, right?
You are not providing
dataTypeso jQuery makes an “intelligent guess” of what the content type is from the responseContent-Typeheader which you said isapplication/json.So jQuery treats the response as JSON which means it will try to automagically parse it as so, causing an error.
Because the request causes an error
the success callback won’t obviously be fired.