Tuesday, 15 July 2014

c# - Passing object to a WebMethod through jquery ajax -


I am trying to pass an object defined to any page method. I'm trying to pass data to collect it from three text boxes. [System.Web.Services.WebMethod] Public Fixed String saveDataToServer (Object CSobage) {// Function Body} {/ P>

Page Method / Code>

JavaScript / jQuery

  $ ("# osmSendMsg"). Click (function () {debugger; var cntDetails ({# CntName: $ ("# osmContactName", "wait", "/ ContactUs.aspx / saveDataToServer", "csObj");});   

PostDataToServer

  // Post data to server (AJAX call). Function PostDataSource (DataTaused, Stormat Gateto Show, StormTyocol, JasonObjectName) { Debugger; / * Includes JSON object in datacentend SubmitType 1 == Submit normal; 2 == Submit and print Strmessageto Show the text that you please wait In the window. * / Var tempurl = strMethodToCall; var tempdata; $ .ajax ({url: tempurl, type: "post", async: false, data type: "jason", data: "{" + json object name +: "+ JSON.stringify (dataToSend) +"} ", // Timeout: 30000, Content Type:" Application / Jason; Charset = UTF-8 ", Success: Function (Data) {tempdata = data;}, Error: Task (result) {tempdata = null;}}; // Ajax call return end of tempdata;} // closing of post data   

is now reaching the call web method. no problem. I am getting an object too. But how do I process the object?

Inside the data

As you can see, The same is what I am getting, I also tried to declare a class and pass it as a parameter .. but all its assets are empty. If you see that the data is visible as a key, then the value pair. I can convert it to a dictionary, but I believe it is a complex solution.

key - value added

A simple solution was welcomed Will go!

Please find the appropriate way to do this, you too can do it.

No comments:

Post a Comment