jQuery .load with MVC 2/3 PartialViews

Ever wanted to re-use or re-load part of your page via AJAX with MVC 2/3. There is a really simple way to achieve this with PartialViews and jQuery’s .load() function.

1.  Create a PartialView

2. Add some jQuery – AJAX .load():

      { param1: "hello", param2: 22}, function () {
	//do other cool client side stuff

3.  Add your MVC Controller ActionResult that returns your PartialView:

public ActionResult GetAwesomePartialView(string param1, int param2)
    //do some database magic
    CustomDTO dto = DAL.GetData(param1, param2);

    return PartialView("AwesomePartialView",dto);

4. Add some client side code to make it happen