jQuery and ASP .NET MVC: browser issues

While I’m learning Ruby on Rails during my personal free time, at work, I’m spending some time trying to ramp up on the new ASP .NET MVC framework. It might not be a good idea to try to learn two languages and frameworks at the same time but it’s tough because for personal projects, I feel like Ruby on Rails is more useful to me.

In any case, I’ve wasted a few hours trying to figure out why my jQuery AJAX method call works in IE but not in Firefox. Isn’t that the whole point of using a library like jQuery (to not have to worry about browser differences)?

In any case, after some smart Google searching, I found this post which indicated that I needed to pass in an empty value for the data parameter in the ajax method call, even if there are no query parameters:

http://encosia.com/2008/06/05/3-mistakes-to-avoid-when-using-jquery-with-aspnet-ajax/
http://encosia.com/2008/03/27/using-jquery-to-consume-aspnet-json-web-services/

Since most ASP .NET MVC applications will implement a REST-style URL with no query parameters, the jQuery method call made to the controller which returns the JSON object should always have a data parameter of “{}”.

Post a Comment

Your email is never published nor shared. Required fields are marked *