Could someone please tell me what is wrong with this code? It works fine in IE8 but not in FF3.
$.get("http://google.com/", function(data) { alert(data); });
It shows me the alert window but it's empty.
I believe it has to do with the cross domain AJAX restrictions between the two browsers. FireFox is more strict (secure) when it comes to AJAX. Your code violates FireFox's "Same Origin Policy"
Hope this helps!
That code shouldn't work in Firefox or IE, due to the same origin policy. Chances are, you've set your security settings for the site's zone to be able to access data across domains:
To change this behaviour (and you probably should), go to Internet Settings -> Security -> Choose the zone for the current site -> Choose Custom level...
Please read the documentation for $.get() (or really any other jQuery AJAX call).
http://api.jquery.com/jQuery.get/
It specifies the following lower down on the page: Due to browser security restrictions, most "Ajax" requests are subject to the same origin policy; the request can not successfully retrieve data from a different domain, subdomain, or protocol.
This is likely the source of your problem.
You cannot use AJAX to send a request to a different domain.
In IE, you apparently enabled this option.
Go to Internet Options, Security, Custom Level, Miscellaneous, and disable Access Data Sources across Domains.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With