jquery-Ajax-Request SyntaxError: Unexpected token <

Ich versuche liefert ein array der Produkte, die mit einer get-Anfrage. Die Antwort liefert XML mit einem 200-Anfrage.

Web-Service:

[WebMethod]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public List<product> GetAllProducts()
{
    using (SchulteDesignYourOwnEntities db = new SchulteDesignYourOwnEntities())
    {
        return db.products.ToList();
    }
}

Hier ist mein code:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

    <head>
        <title></title>
        <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.3.min.js"></script>
        <script type="text/javascript">
            $(document).ready(function () {

                $.ajax({
                    url: 'http://www.organizeliving.com/designwebservice.asmx/GetAllProducts',
                    dataType: 'json',
                    success: function (result) {
                        alert("Result: " + result.length);
                    },
                    error: function (xhr, ajaxOptions, thrownError) {
                        console.log("Status: " + xhr.status);
                        console.log("Message: " + thrownError);
                    }
                });


            });
        </script>
    </head>

    <body></body>

</html>
überprüfen Sie, ob der string-Eigenschaften in zurückgegebenen Produkts Liste enthält < Charakter
Es funktioniert. Mein problem scheint, dass ich nicht zurückkehren kann json aus meiner .asmx-web-service. Meine Antwort ist Soap/ XML.

InformationsquelleAutor Joseph Anderson | 2012-12-05

Schreibe einen Kommentar