
Untitled
By: a guest on
Jul 4th, 2012 | syntax:
None | size: 1.09 KB | hits: 19 | expires: Never
ASP.NET MVC 3 - Can We Use Model Binding Over jQuery AJAX Calls?
function getResults(field1, field2, field3) {
$.get('/Search/GetResults', { id: field1, type: field2, blah: field3 }, function(data) {
$('#target').html(data);
});
}
[HttpGet]
public PartialViewResult GetResults(int id, int type, string blah)
{
var model = repository.GetResults(id, type, blah);
return PartialView("Results", model);
}
function getResults(someModel) {
$.get('/Search/GetResults', { model: someModel }, function(data) {
$('#target').html(data);
});
}
[HttpGet]
public PartialViewResult GetResults(SearchPreferences prefs)
{
var model = repository.GetResults(prefs);
return PartialView("Results", model);
}
var field1 = $('#field1').val();
var field2 = $('#field2').val();
public class SearchPreferences
{
public int id { get; set; }
public int type { get; set; }
public string blah { get; set; }
}
[HttpGet]
public PartialViewResult GetResults(SearchPreferences prefs)
{
var model = repository.GetResults(prefs);
return PartialView("Results", model);
}