开发者

JavaScript object - convert to JSON format and pass to a server side function

With the below code we can store our client side data in dictionary like object through JavaScript:

var Person = {};
Person["EmployeeID"] = "201";
Person["Name"] = "Keith";
Person["Department"] = "Sales";
Person["Salary"] = "25000";

Now I want to know how could I convert the Person object to JSON format and pass to our server side function and client side person object should se开发者_Go百科rialize to server side person object.

My server side function looks like:

[WebMethod]
public static string Save(Person msg)
{

}

So please guide me how to convert the client side person object to JSON format as a result I can send the person data to our server side function with jQuery.


Well, the easy way would be to use jQuery's JSON plug-in and say $.toJSON(Person).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜