Nithin Paul Nithin Paul - 1 year ago 146
Ajax Question

Invalid JSON primitive ERROR

Please Help. In my ajax call getting error Invalid JSON primitive, whats wrong with this following ajax call

url: "/Precedent/ShowPartyContents", type: "POST",
contentType: 'application/json; charset=utf-8',
dataType: 'html',
alert("String"+ result);
//jq("#PartyTagContentArea-"+ pass cheyyenda id).html(data).fadeIn();
error : function( ts ){
alert("error :(" + ts.responseText);




Answer Source

You are promising a content type of application/json but are sending a plain JS Object, which gets serialised as percentile-encoded-string by jQuery. This serialization might be far from valid JSON.


data: {'partyId':party,'PartySelCombo':valueFrom,'DocumentId':DocId},


data: JSON.stringify({'partyId':party,'PartySelCombo':valueFrom,'DocumentId':DocId}),
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download