views:

300

answers:

4

I have a jquery ajax call that is making a cross-domain request. all the js syntax looks good, and the response looks good, but i keep getting the "missing ; before statement error" in firebug (console). Here's my web service:

[WebMethod()]
[ScriptMethod(ResponseFormat = ResponseFormat.Json, XmlSerializeString = false, UseHttpGet = true)]
public string HelloToYou(string name)
{
    return "Hello " + name;
}

here's my javascript:

function HelloToYou() {
    $.getJSON(
        "http://localhost/test/webservicedemo.asmx/HelloToYou?callback=?",
        { name : "nathan" },
        function() { alert("something"); }
    );
}

any ideas?

A: 

Your code looks like it's retrieving jsonp data? If my assumption is correct it might be that the json is invalid and causing the error.

I'm not an interpreter but your javascript code looks ok. If you have access to the json that is retrieved try making it something simple e.g. []

klaaspieter
A: 

Are you sure you've imported the jquery .js file correctly?

theycallmemorty
A: 

I think in your js function missing parameter.. Try this

function HelloToYou() {
    $.getJSON(
        "http://localhost/test/webservicedemo.asmx/HelloToYou?callback=?",
        { name : "nathan" },
        function(data) { alert("something"); }
    );
}
boss
A: 

Very probably the JSON data, which is eval'ed upon being received. The eval() is most likely throwing this error. Check the data via jsonlint.com.

John Howard