Back to blog

Howto use jQuery with mvc preview 4′s AjaxHelper

July 21, 2008 - Posted in .net , Ajax , mvc , c# , javascript Posted by:

Working on jQuery4mvc preview 4, one of the first things I ofcourse wanted to do was to replace the ASP.NET Ajax library that’s used by the AjaxHelper.

Unfortunately the AjaxHelper itself is sealed, so atm we can’t (easily) change how the AjaxHelper generates its links. So, as an alternative, I created a javascript library that uses the same methodnames as the MicrosoftMvcAjax version.

Though at first I was upset that AjaxHelper wasn’t opened up, this javascript-only solution makes it very easy to use. All you have to do is

  • place the latest jQuery version in your Content folder;
  • place my javascript file in your Content folder;
  • add references in your views (or masterpage ofcourse) to these 2 files instead of referencing the MicrosoftMvcAjax.js and MicrosoftAjax.js file.

If you haven’t played with the AjaxHelper yet, take a look at Scott Hanselman’s post on Using Ajax and Ajax.Form

This jQuery version also has a little extra: browser-history support for your ajax requests

Now, go download the js file and play!


Radek Matěj 6 years ago

Thank you for this. It works like a charm!

Tim 6 years ago

I think you and this guy should put your heads together, he’s done some amazing stuff, he’s nearly to the point where jquery will be able to dynamically create forms that are ajax enabled, sort of a client side on the fly scaffolding…,guid,e55bfb55-ac10-48db-98a4-d28343e0f98a.aspx

Gøran 6 years ago

Hi Chris

Nice work! Tim is on to something, we working together. I’ve been super busy since I posted my last jQuery post, and I haven’t had any time to open up a OS project on CodePlex as you have.

I hope we can somehow join the projects and work together, since we solve many of the same problems around asp mvc and Ajax. Please contact me and let me know what you think about that.

Have nice day!


Nate 6 years ago

The method signatures seem to have changed in Preview 5. Any plans to update this script?

Chris van de Steeg 6 years ago

@Nate: you can expect an updated version somewhere this week.

Michiel 6 years ago

Hi Chris, I’m also looking forward to the updated version. They implemented a real breaking change by using the Sys.UI libraries.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>