Add a warning for Firefox 2.0 which rejects XMLHttpRequest to localhost...
authorBrion Vibber <brion@users.mediawiki.org>
Wed, 27 Dec 2006 05:50:07 +0000 (05:50 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Wed, 27 Dec 2006 05:50:07 +0000 (05:50 +0000)
Safari unfortunately seems to let you submit but doesn't actually _work_ on localhost. Doesn't throw an exception here, just never sends a response...

skins/common/ajax.js

index ebc4fd6..4006559 100644 (file)
@@ -96,7 +96,14 @@ function sajax_do_call(func_name, args, target) {
                return false;
        }
        
-       x.open(sajax_request_type, uri, true);
+       try {
+               x.open(sajax_request_type, uri, true);
+       } catch (e) {
+               if (window.location.hostname == "localhost") {
+                       alert("Your browser blocks XMLHttpRequest to 'localhost', try using a real hostname for development/testing.");
+               }
+               throw e;
+       }
        if (sajax_request_type == "POST") {
                x.setRequestHeader("Method", "POST " + uri + " HTTP/1.1");
                x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");