0

I have the follwing method

[WebMethod]
[ScriptMethod(UseHttpGet = false, ResponseFormat = ResponseFormat.Json)]
public List<MyObject> GetMyObjects()
    {
        return Business.GetMyObjects();
    }

as you can see the web method is set to JSON but the method is returning XML

I am using the following JavaScript to access this web method.

function getMyObjects() {
$.ajax({
    type: "POST",
    url: "/treenode/myobjects.asmx/GetMyObjects",
    dataType: "JSON"
}).success(function(data) {
    var response = data.d;
    alert(d.param);
});
}

This may well be a quick fix but I am missing something and cant see what it is.

1 Answer 1

1

by adding an ajax option of

contentType: 'application/json; charset=utf-8'

I overcame the error

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.