AJAX and NS_ERROR_DOM_BAD_URI error

16,744

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/

Share:
16,744
Leastrio
Author by

Leastrio

Web developer

Updated on August 02, 2022

Comments

  • Leastrio
    Leastrio almost 2 years

    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.