jquery - Ajax not passing strings or arrays to MVC Controller -
i have jquery method
var params = { pgroupidents: $.param({ pgroupidents: groupidents }), pisnew: isnew, pnewtypecategoryident: $(detailsnewtypecategory_select).val(), pnewtypetitle: $(detailsnewtypetitle_tb).val(), pexistingtypeident: $(detailsexistingtypecategory_select).val(), pnote: isnew ? $(detailsnewtypenote_tb).val() : $(detailsexistingtypenote_select).val() }; var json = json.stringify(params); $.ajax({ url: "/activities/postextracurricular/setextracurricular/", type: "post", data: json, datatype: "json", processdata: false, contenttype: "application/json; charset=utf-8" }) .always(function () { }) .success(function (data) { }) .fail(function () { });
posting method
public jsonresult setextracurricular(int32[] pgroupidents, bool pisnew, int pnewtypecategoryident, string pnewtypetitle, int pexistingtypeident, string pnote)
and stringified data this
"{"pgroupidents":["12033","12025","12030"],"pisnew":true,"pnewtypecategoryident":"2","pnewtypetitle":"title","pexistingtypeident":"2","pnote":"note"}"
in controller int
parameters work fine, both string
parameters , int32[]
parameters null.
ive tried; adding [httppost]
, traditional: true
, string
vs string
, int[]
vs int32[]
vs ienumerable[int]
ive done before dandy ive no idea whats not working here
you should not stringify params. sending through object fine.
$.ajax({ url: "/activities/postextracurricular/setextracurricular/", type: "post", data: params, datatype: "json", processdata: false, })
Comments
Post a Comment