asp.net - call a webservice with list<int> as paramter from jquery .ajax -
i have webservice webmethod looks like:
[webmethod(description = "gets places category & city")] [scriptmethod(responseformat = responseformat.json)] public list<p> getcitiesps(int categoryid,list<int> cityids) { return mymanager.getps(categoryid, cityids); }
the parameter cityids list of values of checked checkboxes.
var cityids = new array(); $('.city-checkbox').each(function() { checked = $(this).attr('checked'); if (checked == true) { cityid = $(this).attr('value'); cityids.push(cityid); } });
now when call webservice method .ajax,but doesn't fire.
var params = json.stringify({ 'categoryid': categoryid, 'cityids': cityids }); alert(params); $.ajax({ type: "post", url: "finkaynwebservice.asmx/getcitiesps", data: parameters, contenttype: "application/json; charset=utf-8", datatype: "json", success: function(response) { }, failure: function(msg) { alert('somethin went wrong' + msg); } });
why dont use $.post function instead
$.post(url-to-post-to, { data-to-post }, function() { // callback code }, 'json');
Comments
Post a Comment