JQuery: is it possible to instantiate a class on client and pass it to $.ajax to post?

Posted by nisardotnet on Stack Overflow See other posts from Stack Overflow or by nisardotnet
Published on 2010-04-13T15:41:08Z Indexed on 2010/04/13 15:43 UTC
Read the original article Hit count: 323

Filed under:
|
|

what i mean by that is:

i have a class called Customer:

public class Customer
{
    private string _firstName;
    private string _lastName;

    public string FirstName
    {
        get { return _firstName; }
        set { _firstName = value; } 
    }

    public string LastName
    {
        get { return _lastName; }
        set { _lastName = value; } 
    }
}

how do i instantitate the class "Customer" on the client code and add the data and post it? (not sure if this is possible)

here is my client code:
var customer = { "firstName": escape($('#txtFirstName').val()), "lastName": escape($('#txtLastName').val()) };
var jsonText = JSON.stringify({ customer: customer });

$.ajax(
{
type: "POST",
url: "VisitorWS.asmx/AddCustomer",
data: jsonText ,
//data: JSON.stringify(params),
contentType: "application/json; charset=utf-8",
dataType: "json",
...........

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about AJAX