繁体   English   中英

XMLHttpRequest无法加载“此URL”来源Access:Control-Allow-Origin不允许使用原始http:// localhost:3000。

[英]XMLHttpRequest cannot load “THIS URL” Origin http://localhost:3000 is not allowed by Access-Control-Allow-Origin.

我在尝试将POST和XML从我的公司网站发送到FRESHDESK API时遇到此错误

这是javascript

$(document).ready(function(){
  var data = 
  '<helpdesk_ticket>' +
    '<description>This is a test</description>' +
    '<email>sample@example.com</email>' + 
  '</helpdesk_ticket>'
$.support.cors = true;
$.ajax({
    url: 'http://onehouse.freshdesk.com/helpdesk/tickets.xml',
    type: 'POST',
    crossDomain: true,
    data: data,
    dataType: "text",
    username: 'MY API CODE',
    password: 'X',

    success: function (result) {
        alert(result);
    },
  });

完整的错误是

XMLHttpRequest cannot load http://onehouse.freshdesk.com/helpdesk/tickets.xml. Origin http://localhost:3000 is not allowed by Access-Control-Allow-Origin. contacts?oid=00DU0000000I430&retURL=http%3A%2F%2Fwww.ironridge.com&email=ma…utes%5D%5Bdescription_html%5D=safsadfsdaf&00NU0000002xpYP=&submit=Submit:1

有没有人有任何解决方案........它没有将数据发布到FRESHDESK网站,我已经敲了好几天了

它在错误中说它就在那里。

由于Access-Control-Allow-Origin不能对其他域执行任何AJAX请求(除了jsonp )。

这是一个CORS功能(请参阅http://en.wikipedia.org/wiki/Cross-origin_resource_sharing )。 即使您在请求中将crossDomain设置为true ,您发布到的服务器也必须支持CORS才能crossDomain 也就是说,服务器必须使用浏览器的特定HTTP标头进行响应以允许此请求。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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