views:

27

answers:

1

I am using below function to call a function on controller:

  function getPartialView(actionUrl, targetDiv, ajaxMessage, callback) {
        showAjaxMessage(targetDiv, ajaxMessage);

        $.get(actionUrl, null, function (result) {
            $(targetDiv).html(result);
            callback();
        });
    }

and calling it like this:

  getPartialView("UCDamage", "#dvdamageAreaMid", "Loading...", function () { });

this function provides me facility just like updatePanel in classic asp.net web forms. now please tell me how can i pass values in function as a parameter.

actually the UCDamage is a user control which will be randered in div:dvdamageAreaMid. the code is written on current form on which i am displaying this userControl named "UCDamage". but i need to pass some values to this function in controller.

my controller function is like this:

  public ActionResult UCDamage(string searchText)
    {           
        SecureModelService service = new SecureModelService();
        return View(service.ListBodyWork(searchText));
    }

i have tried with taking textbox with namex searchText and retrieve its value but not able to get it.

Please provide me some suggestion and help me out. Thanks

+1  A: 

You can pass values to your controller via the second parameter in your $.get call. Something along the lines of

$.get(actionUrl, { searchText: "hello world" }, function (result) {
        $(targetDiv).html(result);
        callback();
    });

The jQuery documentation has some examples on how to do this: http://api.jquery.com/jQuery.get/

Hector