From bd02ae1dffd02b7e6e1e7744cb37d73e698ff351 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 27 Dec 2006 05:50:07 +0000 Subject: [PATCH] Add a warning for Firefox 2.0 which rejects XMLHttpRequest to localhost... 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 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/skins/common/ajax.js b/skins/common/ajax.js index ebc4fd6039..4006559361 100644 --- a/skins/common/ajax.js +++ b/skins/common/ajax.js @@ -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"); -- 2.20.1