If I have Fi开发者_如何学运维rebug console open, and return the following in a rails controller in response to an ajax call:
format.json { render :json => Appointment.find_by_id(1) }
I get an 'invalid label' error. But it works fine it Firebug is closed.
Any ideas???
What solved it for me was:
jQuery.ajaxSetup({
jsonp: null,
jsonpCallback: null
});
The problem is that the browser treats the json as jsonp and adds a callback to it.
This command solves it (at least for me).
This seems to be related to using JQuery 1.5. Could you confirm that this doesn't happen with JQuery 1.4.4?
I concur with Tomer that this is a json-vs-jsonp problem, but his code didn't fix it for me. I fixed it by adding this jQuery code (works in 1.4 and 1.6):
$(function() {
$.ajaxSetup({
dataType: 'json'
});
});
精彩评论