[英]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.