I\'m trying to populate a div with a partial view in MVC 3. My controller looks like this:
[HttpPost]
public ActionResult GetCustomerList(string searchString)
{
Can you try this to see if it works?
function getCustomerList(searchCriteria) {
$('#customerTabBody').load('@Url.Action("GetCustomerList", "Home")', { 'searchString': searchCriteria });
};
Jquery docs for load says...
The POST method is used if data is provided as an object; otherwise, GET is assumed.
since you are passing data as an object, it has to be a post call according to docs. Furthermore, you are getting required data from controller through $.ajax so controller action method seems to be alright. There may be some error when sending the ajax request using load. you can inspect this in firebug.
I'm fairly certain your .load() call executes a GET request rather than a POST. MVC 3 and most other .NET AJAX transactions (methods decorated as a WebMethod, such as web services and page methods) require data to be POSTed. In this case you'll simply need to stick with what works. As you can see in your working $.ajax() call, the request method is a POST. If you want to short-hand some of the code, use .ajaxSetup() combined with .post().