Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ajax jquery不工作,未进入成功状态_Jquery - Fatal编程技术网

ajax jquery不工作,未进入成功状态

ajax jquery不工作,未进入成功状态,jquery,Jquery,我有一个html页面试图调用下面的ajax jquery调用。如果我将url放在浏览器中,我会将数据取回。第一个警报起作用,显示我们已进入。成功中的警报永远不会弹出,它会转到错误警报。我的代码有什么问题吗 function GetAllStaff() { alert('we R IN'); $.ajax({ type: "GET", url:"http://MyServer/MyService/api/StaffSearch/Ge

我有一个html页面试图调用下面的ajax jquery调用。如果我将url放在浏览器中,我会将数据取回。第一个警报起作用,显示我们已进入。成功中的警报永远不会弹出,它会转到错误警报。我的代码有什么问题吗

        function GetAllStaff() {
        alert('we R IN');
    $.ajax({
     type: "GET",
        url:"http://MyServer/MyService/api/StaffSearch/GetAllStaff",

        data: "{}",
        contentType: "application/json; charset=utf-8",
        cache: false,
        dataType: "json",
        success: function(data) {

            alert('hello world');



        },
        error: function(msg) {

            alert('This is the error: ' + msg.d);
        }
    });
}

这是一个跨域问题,我刚刚添加了行$.support.cors=true;它解决了这个问题。

只要删除数据线,它就会工作。 查找ajax请求问题的一个好方法是使用FireBug

$.ajax({
     type: "GET",
        url:"http://MyServer/MyService/api/StaffSearch/GetAllStaff",
        contentType: "application/json; charset=utf-8",
        cache: false,
        dataType: "json",
        success: function(data) {

            alert('hello world');
        },
        error: function(msg) {
            alert('This is the error: ' + msg.d);
        }
    });

页面是在Web服务器上运行还是在本地运行?返回了什么错误?您得到了什么错误?
数据:“{}”,
您得到的内容真的是json吗?如果服务器想要一个空的json对象,它应该是这样的:
data:{passedData:{},