dongsanhu4784 2013-06-12 17:17
浏览 28

同一域上的Access-Control-Allow-Origin错误

My page has been working for a while now, and all of a sudden its giving me this cross domain request error. The odd thing is I am making a relative request to the file so I do not see why I am getting this.

Error:

OPTIONS https://www.aliahealthcare.com/php/central.php?logout=true Origin https://aliahealthcare.com is not allowed by Access-Control-Allow-Origin.

send jquery-1.7.2.min.js:4 f.extend.ajax jquery-1.7.2.min.js:4 logout aliahealthcare.com/:841 picker aliahealthcare.com/:901 (anonymous function) aliahealthcare.com/:713 f.event.dispatch jquery-1.7.2.min.js:3 h.handle.i jquery-1.7.2.min.js:3

XMLHttpRequest cannot load https://www.aliahealthcare.com/php/central.php?logout=true.

Origin https://aliahealthcare.com is not allowed by Access-Control-Allow-Origin. aliahealthcare.com/:1

Code:

 function logout (){

      $.ajax({
           type: "GET",
           url: "/php/central.php",
                   data: { logout: 'true' },
                   success: function(msg) {
                     if(msg=='1'){ 

                     location.reload();

                    } 
                    else if(msg=='0') {
                        alert("Logout Failed! Please try again!") 
                    }
                  },
                  error:function(msg){
                    alert("Error"+msg);
                    }

         });
     }

Result when outputting result of ajax:

Object {readyState: 1, setRequestHeader: function, getAllResponseHeaders: function, getResponseHeader: function, overrideMimeType: function…} abort: function (a){a=a||"abort",p&&p.abort(a),w(0,a);return this} always: function (){i.done.apply(i,arguments).fail.apply(i,arguments);return this} complete: function (){if(c){var a=c.length;n(arguments),j?l=c.length:e&&e!==!0&&(k=a,o(e[0],e[1]))}return this} done: function (){if(c){var a=c.length;n(arguments),j?l=c.length:e&&e!==!0&&(k=a,o(e[0],e[1]))}return this} error: function (){if(c){var a=c.length;n(arguments),j?l=c.length:e&&e!==!0&&(k=a,o(e[0],e[1]))}return this} fail: function (){if(c){var a=c.length;n(arguments),j?l=c.length:e&&e!==!0&&(k=a,o(e[0],e[1]))}return this} getAllResponseHeaders: function (){return s===2?n:null} getResponseHeader: function (a){var c;if(s===2){if(!o){o={};while(c=bG.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c} isRejected: function (){return!!i} isResolved: function (){return!!i} overrideMimeType: function (a){s||(d.mimeType=a);return this} pipe: function (a,b,c){return f.Deferred(function(d){f.each({done:[a,"resolve"],fail:[b,"reject"],progress:[c,"notify"]},function(a,b){var c=b[0],e=b[1],g;f.isFunction(c)?i[a](function(){g=c.apply(this,arguments),g&&f.isFunction(g.promise)?g.promise().then(d.resolve,d.reject,d.notify):d[e+"With"](this===i?d:this,[g])}):i[a](d[e])})}).promise()} progress: function (){if(c){var a=c.length;n(arguments),j?l=c.length:e&&e!==!0&&(k=a,o(e[0],e[1]))}return this} promise: function (a){if(a==null)a=h;else for(var b in h)a[b]=h[b];return a} readyState: 0 responseText: "" setRequestHeader: function (a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this} state: function (){return e} status: 0 statusCode: function (a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this} statusText: "error" success: function (){if(c){var a=c.length;n(arguments),j?l=c.length:e&&e!==!0&&(k=a,o(e[0],e[1]))}return this} then: function (a,b,c){i.done(a).fail(b).progress(c);return this} __proto__: Object

  • 写回答

1条回答 默认 最新

  • dsf55s1233 2013-06-12 17:25
    关注

    The difference between the URLs is the "www.", and I think that's enough to trigger "cross-domain". You're right that it's strange for a relative request to result in a dissimilar URL; perhaps it's something to do with JQuery's ajax method. You may be able to quickly fix the issue by either entering in the full hostname manually, or determining it with window.location

    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?