HTTP状态“200”但错误触发 [英] HTTP status “200” but error fires

查看:672
本文介绍了HTTP状态“200”但错误触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$.ajax({
            type: "GET",
            url: "http://shoperola.com/Restaurant/foodysrest/sample",
            crossDomain: true,
            cache: false,
            dataType: "json",
            Complete: function(xhr) {xhr.getResponseHeader("Accept", "json")}, 
            success: function (data, textStatus, xhr) {
                console.log(data);
                console.log(xhr.getResponseHeader("Content-Length"));
            },
            error: function (xhr, textStatus, errorThrown) {
                console.log(errorThrown+"---"+textStatus);
            }
        });





此代码返回HTTP状态200但会触发错误。请任何人建议我如何执行网络服务。



这是错误:XMLHttpRequest无法加载http://shoperola.com/Restaurant/foodysrest/sample? _ = 1389172009980。请求的资源上没有Access-Control-Allow-Origin标头。因此不允许原点'http://< localhost>:3294'访问。



this code returns HTTP status "200" but fires error. please any one suggest me how to perform a webservice.

this is the error : "XMLHttpRequest cannot load http://shoperola.com/Restaurant/foodysrest/sample?_=1389172009980. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://<localhost>:3294' is therefore not allowed access."

推荐答案

.ajax({
type: GET
url: http://shoperola.com/Restaurant/foodysrest/sample
crossDomain: true
cache: false
dataType : json
完成: function (xhr){xhr.getResponseHeader( 接受 json)},
成功: function (data,textStatus,xhr){
控制台 .log中(数据);
console .log(xhr.getResponseHeader( 内容长度));
},
错误: function (xhr,textStatus,errorThrown){
console .log(errorThrown + --- + textStatus);
}
});
.ajax({ type: "GET", url: "http://shoperola.com/Restaurant/foodysrest/sample", crossDomain: true, cache: false, dataType: "json", Complete: function(xhr) {xhr.getResponseHeader("Accept", "json")}, success: function (data, textStatus, xhr) { console.log(data); console.log(xhr.getResponseHeader("Content-Length")); }, error: function (xhr, textStatus, errorThrown) { console.log(errorThrown+"---"+textStatus); } });





此代码返回HTTP状态200但会触发错误。请任何人建议我如何执行网络服务。



这是错误:XMLHttpRequest无法加载http://shoperola.com/Restaurant/foodysrest/sample? _ = 1389172009980。请求的资源上没有Access-Control-Allow-Origin标头。因此不允许原点'http://< localhost>:3294'访问。



this code returns HTTP status "200" but fires error. please any one suggest me how to perform a webservice.

this is the error : "XMLHttpRequest cannot load http://shoperola.com/Restaurant/foodysrest/sample?_=1389172009980. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://<localhost>:3294' is therefore not allowed access."


这篇关于HTTP状态“200”但错误触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆