问题描述
我正在使用这个页面 - http://ecmazing.com/cors.html - 制作对此资源的跨域 Ajax 请求:http://hacheck.tel.fer.hr/xml.pl
它适用于 Chrome、Safari 和 Firefox,但不适用于 IE9 和 Opera.
代码:
var pdata = {'textarea': 'test'};$.post('http://hacheck.tel.fer.hr/xml.pl', pdata, function(data, status, xhr) {output.value = xhr.responseText;});(预期结果是一个 XML 代码字符串.)
自己看看: http://ecmazing.com/cors.html一个>
在 IE9 和 Opera 中,XHR 对象的 error 处理程序执行并传入此错误对象:
<代码>{就绪状态:4,状态:0,状态文本:'错误'}如您所见,这个错误对象并没有透露太多信息.
如何让它在 IE9 和 Opera 中运行?
查看 cors at whencaniuse 的条目.p>
对于 Internet Explorer,CORS 是在 IE8 和 IE9 中使用 XDomainRequest 对象支持",因此您需要使用备用对象来使用它.
Opera 根本不支持它.
如果你在 Opera 中需要跨域 Ajax,那就使用 JSON-P.
I am using this page - http://ecmazing.com/cors.html - to make a cross-origin Ajax request to this resource: http://hacheck.tel.fer.hr/xml.pl
It works in Chrome, Safari and Firefox, but doesn't in IE9 and Opera.
The code:
var pdata = {'textarea': 'test'};
$.post('http://hacheck.tel.fer.hr/xml.pl', pdata, function(data, status, xhr) {
output.value = xhr.responseText;
});
(The expected result is an XML code string.)
See for yourself: http://ecmazing.com/cors.html
In IE9 and Opera, the error handler of the XHR object executes and this error object is passed in:
{
readyState: 4,
status: 0,
statusText: 'error'
}
As you can see, this error object doesn't reveal much information.
How can I make it work in IE9 and Opera?
See the entry for cors at whencaniuse.
For Internet Explorer CORS is "Supported somewhat in IE8 and IE9 using the XDomainRequest object", so you need to use an alternate object to use it.
Opera simply doesn't support it.
If you need cross-domain Ajax in Opera, then use JSON-P.
这篇关于跨域 Ajax 请求在 Opera 和 IE9 中不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!



大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)