I am using ajax for the request I am passing a parameter key
and a model to controller method but I can get the key on the method but getting the model value is always null when I am setting the traditional
value true and 0 when I am sending it without traditional.
Here is my ajax method.
$('.search-hot-destination').on('click', '.rightdesti-list > a', function () { var key = $(this).parents('li').find('.countryNameList').attr('id'); var model ={ DestinationCityID: $(this).attr('id') } $.ajax({ type: "GET", url: "/Home/destination", data: {key: key, model:model}, contentType: "application/json; charset=utf-8", dataType: "json", success: function (data) { alert('hello'); } }) });
Here is my controller method.
public ActionResult destination(string key, FilterDataViewModel model, string searchingkey, int skip = 0)
{
}
Here is my Model.
public class FilterDataViewModel
{
public int ItemID { get; set; }
public string SearchingKey { get; set; }
public int DestinationCityID { get; set; }
public int citykey { get; set; }
}
在您的Ajax请求中,您应该JSON.stringify(Object);
data: JSON.stringify({key: key, model:model}),
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.