AJAX 和 NS_ERROR_DOM_BAD_URI 错误 [英] AJAX and NS_ERROR_DOM_BAD_URI error

查看:22
本文介绍了AJAX 和 NS_ERROR_DOM_BAD_URI 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直遇到以下问题,我认为这可能是因为我的方法可能被误导了,但希望在您的帮助下我可以解决这个问题!

I have been having the following problem, i think it's probably due to the fact that my approach may be misguided, but hopefully with your help i can sort this out!

基本上,对于我的网站,我有一个搜索提供商(已付款,所以我没有违反任何使用条款).提交搜索表单后,我会被定向到显示结果的域.

Basically, for my site i have a search provider (who has been paid, so i am not breaking any terms of use). When the search form is subbmitted i am directed to their domain where the results are displayed.

虽然我可以自定义返回结果的外观,但到目前为止我只能接受它,并且永远不会让它完全适合我网站的外观.

Whilst i can customise the look of the returned results, there is only so far i can take this, and will never get it fitting in fully with the look and feel of my site.

所以,我想,不是通过表单进行常规的 GET,我会做一个 AJAXified GET,然后将返回的响应注入页面上的 div - 让我保持外观和感觉,永远不会离开我们的域.

So, i thought, instead of doing the regular GET via the form, i would do an AJAXified GET and then inject the returned response into a div on the page - allowing me to maintain the look and feel and never leave our domain.

这在 IE 中工作正常,但在 Firefox 中我收到text/html (NS_ERROR_DOM_BAD_URI)"作为错误.做了一些研究后,我发现这是由于 AJAX 请求访问了我们域外的站点.

This works fine in IE but in firefox i get "text/html (NS_ERROR_DOM_BAD_URI)" as an error. Having done some research i have discovered this is due to the AJAX request hitting a site outside of our domain.

因此,我可以采取更好的方法来达到相同的效果吗?或者有没有办法让我的 Firefox 和我的 AJAX 请求玩得开心?真正奇怪的是,如果我观察 HttpFox 中的请求(一个整洁的 FF 插件),它会报告上述错误,但查看返回的内容,它完全符合预期 - 那么为什么我不能访问它!!

Thus, is there a better approach i can take to achieve the same effect? or is there a way i can get firefox and my AJAX request to play nice? What is really strange is that if i observe the request in the HttpFox (a neat FF add on), it reports the above error, but looking at the content returned it is all there as expected - so why can't i access it!!

我真的很想让它工作,因为它比重写我们所有的 CSS 和其他东西来让他们的结果页面看起来几乎像我们的网站要简单得多.在这方面的任何帮助将不胜感激.

I would really like to get this to work as it is a whole lot simpler than rewriting all our CSS and stuff to get their results page looking almost like our site. Any help in this area would be much appreciated.

推荐答案

据我所知,你必须使用 JSONP 来做跨域 - 这是 AJAX 中的安全异常.JQuery 处理得很好,但是,您必须修改服务器回复以匹配它.

You'll have to use JSONP to do cross domain as far as I know - it's a security exception in AJAX. JQuery handles it nicely but, you will have to have the server reply modified to match it.

我已经为 Social Actions 完成了一个 OSS 项目,该项目使用 PHP 代理执行此操作.您可以在这里查看:http://os.adamaltemus.com/social-actions/

I have done an OSS project for Social Actions that does this using a PHP proxy. You can look at it here: http://os.adamaltemus.com/social-actions/

这篇关于AJAX 和 NS_ERROR_DOM_BAD_URI 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆