简体   繁体   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.

Im getting this error when trying to POST and XML from my company website to FRESHDESK API 我在尝试将POST和XML从我的公司网站发送到FRESHDESK API时遇到此错误

here is the javascript 这是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);
    },
  });

the full error is 完整的错误是

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

Does anyone have any solutions to this........it does not post the data to the FRESHDESK WEBSITE and i've been banging my heads for days now 有没有人有任何解决方案........它没有将数据发布到FRESHDESK网站,我已经敲了好几天了

It says it right there in the error. 它在错误中说它就在那里。

You cannot do any AJAX requests (aside from jsonp ) to a different domain due to Access-Control-Allow-Origin . 由于Access-Control-Allow-Origin不能对其他域执行任何AJAX请求(除了jsonp )。

This is a CORS feature (see http://en.wikipedia.org/wiki/Cross-origin_resource_sharing ). 这是一个CORS功能(请参阅http://en.wikipedia.org/wiki/Cross-origin_resource_sharing )。 Even though you set crossDomain to true in your request, the server that you post to has to support CORS for this to work. 即使您在请求中将crossDomain设置为true ,您发布到的服务器也必须支持CORS才能crossDomain Namely, the server has to respond with specific HTTP headers for the browser to allow this request. 也就是说,服务器必须使用浏览器的特定HTTP标头进行响应以允许此请求。

暂无
暂无

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

相关问题 XMLHttpRequest无法加载http:// localhost:8081 / sample.xml。 Access-Control-Allow-Origin不允许使用null。 - XMLHttpRequest cannot load http://localhost:8081/sample.xml. Origin null is not allowed by Access-Control-Allow-Origin. XMLHttpRequest无法加载http://ideone.com/api/1/service.wsdl。 Access-Control-Allow-Origin不允许使用Origin null。 - XMLHttpRequest cannot load http://ideone.com/api/1/service.wsdl. Origin null is not allowed by Access-Control-Allow-Origin. XMLHttpRequest无法加载http:// localhost:8089 / jquery。 Access-Control-Allow-Origin不允许使用原点null - XMLHttpRequest cannot load http://localhost:8089/jquery. Origin null is not allowed by Access-Control-Allow-Origin XMLHttpRequest无法加载请求的资源上不存在“Access-Control-Allow-Origin”标头。 Origin'http:// localhost:3000'Google maps - XMLHttpRequest cannot load No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' Google maps Access-Control-Allow-Origin不允许起源。 - Origin is not allowed by Access-Control-Allow-Origin. Access-Control-Allow-Origin不允许Angularjs Rails- Origin http:// localhost:9000。 - Angularjs Rails- Origin http://localhost:9000 is not allowed by Access-Control-Allow-Origin. XMLHttpRequest无法加载Access-Control-Allow-Origin不允许使用Origin - XMLHttpRequest cannot load Origin is not allowed by Access-Control-Allow-Origin XMLHttpRequest无法加载URL。 Access-Control-Allow-Origin不允许原点 - XMLHttpRequest cannot load URL. Origin not allowed by Access-Control-Allow-Origin Android webview - XMLHttpRequest无法加载Origin <url> Access-Control-Allow-Origin不允许使用 - Android webview - XMLHttpRequest cannot load Origin <url> is not allowed by Access-Control-Allow-Origin XMLHttpRequest无法加载url Access-Control-Allow-Origin不允许使用Origin null - XMLHttpRequest cannot load the url Origin null is not allowed by Access-Control-Allow-Origin
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM