Getting an error “ 'JSON' is undefined ” in webservices

codeboyx

New Member
I am new to webservice and Json. I am developing an application in asp.net which uses Webservices and Json for Posting data in Ajax call to Server.In the below fuction PostData i am getting an error at --->\[code\] data: "{" + jsonObjectName + ":" + JSON.stringify(dataToSend) + "}", as "json" is undefined. \[/code\]Here dataToSend is an object which contains my data submitType--> is submit button id (in page this i have two submit buttons so, i called by id)strMessagetoShow--->is text to show success or failure.strMethodToCall--> which method is called in Webservice.Please help me.\[code\] function PostData(dataToSend, submitType, strMessagetoShow, strMethodToCall, jsonObjectName) { $.ajax({ url: window.top.GetWsUrl() + "/" + strMethodToCall, type: "POST", dataType: "json", data: "{" + jsonObjectName + ":" + JSON.stringify(dataToSend) + "}", timeout: 30000, contentType: "application/json; charset=utf-8", success: function (data) { return data; }, error: function (result) { alert(result.status + ' ' + result.statusText); }});\[/code\]}
 
Back
Top