Reputation: 3747
Am receiving a JSON object from webservice in C# using the below script
$.ajax({
type: "POST",
url: "Services/LogService.asmx/authenticateLogin",
data: "{'gopId':'" + txtGopId+ "'}",
contentType: "application/json; charset=utf-8",
success: function (response)
{
var k = $("#hidId").val(response.d);
window.location.replace("Pages/Reved.aspx?hid="+k+"");
},
error: function (xhr, status, error) {
DisplayError(xhr);
}
});
hidId is a hidden feild.
On sucess am forwarding the Object to another aspx page and trying to deserialize this on page_load
JavaScriptSerializer serializer = new JavaScriptSerializer();
userBO = serializer.Deserialize<UserBO>(Request["hid"]);
Am I doing some thing wrong? as iam facing this error: Invalid JSON primitive: object
Upvotes: 2
Views: 6512
Reputation: 16583
The "Invalid JSON primitive" error message means that whatever you're sending to the deserializer is not JSON. Have you verified that the value you're putting into the hidId field is valid JSON?
Upvotes: 4