I am currently developing a Ruby on rails 3 application.
My server manager function displays the json object as the answer:
class DaysController < BaseController
...
def the_days
...
render :json => days
end
end
In my javascript, I use the following code to get a json response from the server (which is from a function the_dayin the controller)
$.getJSON(
url,
{emp_id: emp_id},
function(data) {
var result = data.response;
alert(result)
alert(data)
},
"json"
);
I use firefox browswer and verified with Firebug , in Firebug Net-> XHR, I see that the Get request is successful, and there is a "days" answer. This request and response are successful.
But I did not see the two warning windows defined in the function above $.getJSON, why? Why can not I get the answer " days " in the function $.getJSON?
----------------- ------------------ Edited
I edited my code:
$.ajax({
url: myURL,
type: 'GET',
data: {
emp_id: emp_id
},
dataType: "json",
success: function(data) {
alert("hi");
alert(data)
}
});
, success: function(data)