Can not get json response using $.getJSON
Posted
by
Mellon
on Stack Overflow
See other posts from Stack Overflow
or by Mellon
Published on 2011-02-13T15:11:02Z
Indexed on
2011/02/13
15:25 UTC
Read the original article
Hit count: 246
I am currently developing a Ruby on rails 3 application.
My server controller function render a json object as response:
class DaysController < BaseController
...
def the_days
...
render :json => days
end
end
In my javascript,I use the following code to get json response from server( that's from the_day
function in controller)
$.getJSON(
url,
{emp_id: emp_id},
function(data) {
var result = data.response;
alert(result)
alert(data)
},
"json"
);
I use firefox browswer and checked with Firebug, in Firebug Net->XHR, I see the Get request is successful, and the response "days" is there. That's both request and response are successful.
But I did not see the two alert window defined in the above $.getJSON
function, why? Why I can not get the response "days" in $.getJSON
function??
© Stack Overflow or respective owner