getJSON call working on IE 7 but not Firefox 3

Question!

I have a web application that uses the current version of JQuery that needs to get some JSON objects back from a REST web service. I'm using the following call to $.getJSON:

$.getJSON("http://localhost:17245/Service.svc/?format=json", function(data) {alert(data.id);});

This call works fine in IE7 and I can call the service with no problem in Fiddler. I've stepped through this in Firebug, but when Firefox gets to this line the javascript execution just seems to "die" with no error, no call back, no nothing.

I've also used $.ajax and have the same issue; works fine in IE, nothing in Firefox.

Anyone have any ideas? I'm VERY new to JQuery, so please be gentle.

Thanks, James



Answers

Not sure if it was ever solved, but it looks like cross site scripting restrictions in Firefox. It treats port numbers on your development ASP.NET server (localhost:0000) as different domains. Try to host both: service and the web application, on IIS which doesn't use port numbers.

By : vwemil


I just ran into this problem and found that the root cause was a trailing comma in the JSON that's getting returned.



This video can help you solving your question :)
By: admin