简体   繁体   中英

What is the jscript mistake in VS2012 Project?

this is my script

$(document).ready(function () {
        $.ajax({
            type: "Post", dataType: "json", contentType: "application/json; charset=utf-8",
            url: "http://localhost:63384/ListWebService.asmx/Helloworld", success: function (data) { alert(data.d); }, error: function (request, status, error) {
                alert(request.responseText);
            }
        });
    });

In the Hello World i am returning "Hello World". i am getting output correct in vs 2010 project but in VS 2012 Project the same code produces alert box with "undefined" as output.

当您给您url时,您无需提供完整的路径,只需编写ListWebService.aspx / Helloworld。

Do you have jQuery included? Check with fiddler or dev tools (F12) if the call to the aspx actually happens... Post us code demo so we can debug....

Firstly it seems ur not posting any data but rather only fetching data from webservice. Whats wrong with 'GET' request?

use a debugging tool firebug to find what response ur getting back.

example 在此处输入图片说明

use breakpoint inside ur success method to break into the code and find what is being held in the 'data'.

learn to use debugging tools (f12) it will save your time and even may be a little bit of your hairs...lol :P

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM