I have the following javascript code:
$.get("categories/json_get_cities/" + stateId, function(result) {
And the PHP code that processes it basically outputs something like this:
function json_get_cities($stateId) { //code here echo json_encode(array('cities'=>$cities)); }
In the firebug console, I see that the ajax request is executing as expected, a 200 OK response is received, and a valid JSON object containing cities is returned. However, for some reason, the callback function I pass to jquery is not called.
Even putting a debugger call at the top of the function, i.e.
$.get("categories/json_get_cities/" + stateId, function(result) { debugger;
does not work. However, if I delete the third argument to βjsonβ, then the function is called (but the response text is treated as plain text, not as a JSON object).
Here is the JSON response returned by the server:
{"cities":[{"id":"1613","stateId":"5","name":"Acton"}]}
Any thoughts?
source share