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)
.
精彩评论