I managed to setup a simple webmethod which i called from jquery and sure enough it returns ... then i added parameters on the method and added the params to jquery but it errors with

        Message":"Invalid JSON primitive: one.","StackTrace":"

my signature on my webmethod is like so

    [WebMethod]
    public static string GetDate(string one, string two)
    {
        return "yes";
    }

and my jquery is like this, what am i doing wrong?

                $.ajax({
                type: "POST",
                url: "MyService.aspx/GetDate",
                data: { one: "value", two: "value" },
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function(msg) {
                    alert(msg.d);
                },
                error: function(msg) {
                alert('error');
                }

            });
share|improve this question

1 Answer

up vote 4 down vote accepted

Try enclosing your data parameter in quotes:

data: '{ one: "value", two: "value" }',
share|improve this answer
1  
data: "{ 'one':'value', 'two':'value'}" would also work. +1 – ichiban Jun 1 '09 at 20:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.