JQuery ajax Aufruf httpget webmethod (c#) funktioniert nicht

Ich versuche zu bekommen eine ajax-get zu einer webmethod in code hinter. Das problem ist, ich erhalte die Fehlermeldung "parserror" aus dem jQuery - onfail Methode.

Wenn ich die BEKOMMEN ein POST alles funktioniert einwandfrei. Bitte siehe meinen code unten.

Ajax-Call

<script type="text/javascript">
        var id = "li1234";

        function AjaxGet() {
            $.ajax({
                type: "GET",
                url: "webmethods.aspx/AjaxGet",
                data: "{ 'id' : '" + id + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                async: false,
                success: function(msg) {
                    alert("success");

                },
                error: function(msg, text) {
                    alert(text);
                }
            });
        }

    </script>

Code Hinter

[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod(UseHttpGet = true,
    ResponseFormat = System.Web.Script.Services.ResponseFormat.Json)] 
public static string AjaxGet(string id)
{
    return id;
}

Web.config

        <webServices>
            <protocols>
                <add name="HttpGet"/>
            </protocols>
        </webServices>

Der URL verwendet wird

......../webmethods.aspx/AjaxGet?{%20%27id%27%20:%20%27li1234%27}

Als Teil der Reaktion ist die Rückkehr der html-Code für die Seite webmethods.

Jede Hilfe wird sehr geschätzt.

InformationsquelleAutor Tim Jarvis | 2010-04-16

Schreibe einen Kommentar