AJAX and NS_ERROR_DOM_BAD_URI error

2019-02-22 05:58发布

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.

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.

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.

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!!

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.

标签: html ajax get
3条回答
甜甜的少女心
2楼-- · 2019-02-22 06:07

It's also possible if you're currently on a http webpage and are trying to send an AJAX call to a https website on the same domain.

查看更多
三岁会撩人
3楼-- · 2019-02-22 06:12

This error occurs if you have given different domain name in the code. http://hiox.org/index.php?id=2737

查看更多
小情绪 Triste *
4楼-- · 2019-02-22 06:16

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.

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/

查看更多
登录 后发表回答