I am getting “System.ArgumentException: Invalid JSON primitive: pagenum” when I return “sdata” in the following code:
function getPageData() {
pagenum = parseInt(eSc("#resultsBtn").attr("data-pagenum"));
if (pageName === "Home") {
scrollPath = "/Home/GetResults/";
sdata = { "pagenum": pagenum, "sortType": sortType };
}
else if (pageName === "Search") {
scrollPath = "/SearchAjax/GetResultsKeyword/";
sdata = { "pagenum": pagenum, "sortType": sortType, "keyword": keyword };
}
else if (pageName === "Cat") {
scrollPath = "/SearchAjax/GetResultsCategory/";
sdata = { "pagenum": pagenum, "sortType": sortType, "ID": categoryId, "Level": level };
}
else if (pageName === "Merchant") {
scrollPath = "/SearchAjax/GetResultsMerchant/";
sdata = { "pagenum": pagenum, "sortType": sortType, "ID": merchantId };
}
}
and the init function on pageload:
function init(a, b, c, d, e, f, g) {
getPageData();
eSc.ajax({
type: 'POST',
url: scrollPath,
data: sdata,
success: function (data) {
eSc("#moreResults").html(data);
}
});
}
users dont see an issue and the correct data is still returned, yet I am getting an error email every time someone loads more data from our site in production (doesnt happen in development so its hard to troubleshoot). When inspecting in firebug, I see the correct data is passed. So why am I still getting this error?!
Any tips as to why this might be happening?
pass sData in json format, using JSON.stringify to format data in json format.
It works in my case. Hope it work in your case.