Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.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
Jquery AJAX响应,不显示在success函数中_Jquery_Ajax_Json_Web Services - Fatal编程技术网

Jquery AJAX响应,不显示在success函数中

Jquery AJAX响应,不显示在success函数中,jquery,ajax,json,web-services,Jquery,Ajax,Json,Web Services,我正在尝试使用第三方web服务来获取数据,使用ajax。 提供web服务的家伙们给了我一个链接和一个关于如何获取数据的小说明,我觉得我很接近,但我无法让它工作。 下面是他们给我的: 生产URL:“” 调用:getDeviceData(字符串用户名、字符串密码、字符串 激活代码) 该函数应该返回JSON响应,或以下一些错误代码:-1-1001; -2001; -3001; $.ajax({ url: '//www.locationbasedtech.net/webservice.asmx/

我正在尝试使用第三方web服务来获取数据,使用ajax。 提供web服务的家伙们给了我一个链接和一个关于如何获取数据的小说明,我觉得我很接近,但我无法让它工作。 下面是他们给我的:

生产URL:“” 调用:getDeviceData(字符串用户名、字符串密码、字符串 激活代码)

该函数应该返回JSON响应,或以下一些错误代码:-1-1001; -2001; -3001;

$.ajax({
    url: '//www.locationbasedtech.net/webservice.asmx/getDeviceData?username=myusername&password=mypassword&activationCode=mycode',
    contentType: "application/x-www-form-urlencoded",
    dataType: "script",
    success: function(data) { 
                console.log(data);//returns 'undefined' ??
    },
    error: function(request,status,errorThrown){
                console.log(request+' '+status+' '+errorThrown);              
    }
}) ;
现在,我已经能够使它只与数据类型:“脚本”一起工作。其他人都回来了

No 'Access-Control-Allow-Origin' header is present on the requested resource.

无论如何,上述代码的工作方式是,我可以在控制台链接“preview”或“source”中看到正确的(无错误json结果),但success函数返回“undefined”。如何获得响应?

如果他们不支持CORS或提供JSONP服务,您将无法直接从JavaScript查询该服务。如果他们通过JSONP支持跨源,请尝试以下方法:谢谢大家,我将与支持人员联系。你有没有想法,即使不是ajax,我如何让它工作?也许是php?