Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
455 views
in Technique[技术] by (71.8m points)

asp.net - HTTP 500 Error jQuery Ajax with Web service

I have two simple projects in a single Visual Studio solution to understand how a jQuery ajax request works. One is a web service and the second one is a project consuming the web service.

You can download the very small project from here. Download Project file

As you can see in the project, Whenever I try to call the Web Service, Internal Server Error 500 is occurring.

In chrome, I can see the following alert (executed by "Error" function of Ajax call)

enter image description here

Please assist me to find the problem..

EDIT:

function btnClick() {
        debugger;
        var txtValue = $('#txtValue');
        var text = txtValue.val();
        //
        //
        $.ajax({
            url: "http://localhost:12000/ExampleJsonWS.asmx/getValue",
            type: "POST",
            dataType: "json",
            data: "{" + txtValue.val() + "}",
            timeout: 30000,
            async: false,
            contentType: "application/json; charset=utf-8",
            success: function (data) {
                debugger;
                alert(data);
                return data;
            },
            error: function (result) {
                debugger;
                //alert(e);
                alert(result.status + ' ' + result.statusText);
            }
        });
    }
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The problem was that its not possible to POST with keeping the web service in different project while a GET can do that. (Explained by Phillip Haydon). If I understand it wrong or someone want to share more about it, then they are welcome :)

For more info you can have a look at this link

The better alternative is to keep a Web service inside the project and call the other Webservice (which is needed) into the Project's web service.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...