var test = JSON.stringify({ selectedIds: selectedIds });
debugger;
$.ajax({
type: "POST",
url: $.Handler('UserAdmin', 'MassDelete'),
contentType: 'application/json',
traditional: true,
data: JSON.stringify({ selectedIds: selectedIds }),
success: function (data) {
if (data.success === true) {
//reload grid\data table.
this.ajax.reload();
//reset selected Ids.
selectedIds.length = 0;
alert("Record(s) deleted!");
}
else {
alert("Failed to delete record(s)! ");
}
},
error: function (event, xhr, options, exc) {
debugger;
alert("Ajax error!");
}
});
Result of test
is {"selectedIds":[1,2,4,5,6,7,8,9,10,11]}
I verify it using https://jsonlint.com/
It said it's a valid json.
But I am getting this error from error: function (event, xhr, options, exc)
, in event
:
Invalid JSON primitive: __RequestVerificationToken=8_FtxCCCbCMCFCTJ_pPyITT-e5fd74ETemgrKVYtDNho_RPIOjRhDAlDYYO46dlRRVjX2DDI91bl-5nn7uspOzXBX8zyzJut5KmagSMkfA_rySSVxh4qPIBl0GSdNjRO0.
I can't even reach c# code:
[HttpPost]
public JsonResult MassDelete(int[] selectedIds)
{
return Json(new { success = true });
}
Request URL:
http://localhost:51308/UserAdmin/MassDelete
Request headers:
Accept: /
Accept-Encoding: gzip, deflate
Accept-Language: en-SG
Cache-Control: no-cache
Connection: Keep-Alive
Content-Length: 178
Content-Type: application/json
Cookie: EPSCookies=1955EA20BDCF7AC5E47E0EC3A4062866C7F8FE177B11D90FE70C08D14468D26F9CAAEDA7B86A4E719F078AAF72947FFE1C7A99047E5D5AE28E9B50179C36617EA7EF1615283B580CAD0BBD5F9D54BA8E32F89AC358AAAB861614A1D39B3C1C1174F6CD9C387B013506C9BA85399B6C1CBEE4C9CA2B056CAF97AF5C052B4787407BA7183B63EAC4A1160734FBF37605F998E2B9649B9F14E9A2A9597EB9316BB3779C49BE254F2989E5872531B4E46012610702C608D03EDB29AA0433FC1B2445228398D35F64554266C0F60F0997B92A560E1F9D0F0D321E2E4CF5662BE05EB5190DECA192BB705D0D3A0EC52FA886D6BF2038F64A344AF49E3AEFDB81ED416B5D54DD931F70D0CA993A482CBF90B9E01D02102CE160079BA32A0D464DA0D04AED99E05458BD936087015EE79BBD3FECE557329269D0403A4F2BD5F2D9101F1F97D965C5FE6303EAEF509BB412F6312D; ASP.NET_SessionId=ggrvlp4dzpexnaxii4nathsy; __RequestVerificationToken=OKOef4WDNzJdymQ8O6PeVkvnW04fvXVtlbn4sI7IcF8Q9Wta3uZIfiI7h-50bH1D7OF0DcBfrM_3L8s90dR6_L7ZkhQ26RT4Lr64TGPFWRM1
Host: localhost:51308
Referer: http://localhost:51308/UserAdmin/UserSkillMatrixOverview
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko
X-Requested-With: XMLHttpRequest
Response Headers:
Cache-Control: private
Content-Length: 11061
Content-Type: text/html; charset=utf-8
Date: Fri, 08 Nov 2019 08:49:34 GMT
Persistent-Auth: true
Server: Microsoft-IIS/10.0
X-AspNet-Version: 4.0.30319
X-Frame-Options: AllowAll
X-Powered-By: ASP.NET
X-SourceFiles: =?UTF-8?B?RDpcVEZTXEFUU19NSVNQcm9qZWN0Q29sbGVjdGlvblxNYW51ZmFjdHVyaW5nXE1haW5cRWxlY3Ryb25pY1B1bGxTeXN0ZW1cU291cmNlXEVQU1xFbGVjdHJvbmljUHVsbFN5c3RlbVxVc2VyQWRtaW5cTWFzc0RlbGV0ZQ==?=