The following JQuery get
call:
var doc_root = document.location.hostname + ":8082";
var fw_script = doc_root + "/sites/MyScripts/fw2.php";
var langpref = "EN";
var ttype = "BEGIN";
var vvalue = $("#inp_begin").val();
$.get(fw_script, { type: ttype, value: vvalue, langpref: langpref })
.success(function(result) {
$(fw_result).text(result);
alert("Success");
})
.error(function(jqXHR, textStatus, errorThrown) {
$(fw_result).text("Error: " + textStatus + " " + errorThrown);
alert("Failure");
});
is generating the following error message (.error
is called):
Error: error [Exception... "Component returned failure code: 0x805e0006
[nsIXMLHttpRequest.open]" nsresult: "0x805e0006 (<unknown>)" location: "JS frame ::
http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js
:: <TOP_LEVEL> :: line 4" data: no]
I have no idea what this message is and I can't find much explanation with my Googling. Can anyone clarify?
UPDATE
The called URL is constructed as following in Javascript:
var doc_root = document.location.hostname + ":8082";
var fw_script = doc_root + "/sites/MyScripts/fw2.php";
and fw_script
's value is:
fw.localhost:8082/sites/MyScripts/fw2.php
It is called from
fw.localhost:8082/en
When I try fw.localhost:8082/sites/MyScripts/fw2.php
in my browser, it is successful.
Just to call attention to the sleuthing done by @nrabinowitz and other commenters: check your ad blocker/privacy plugin. In my case, Privacy Badger started blocking
localhost
.Looks very likely that you're dealing with a cross-domain request error. According to the Same Origin Policy, you can't make an AJAX request to a host with a different port number, even if it's the same domain. It looks like you're setting
doc_root
to a different origin, by this definition, so you'll likely get an error on the AJAX request.The standard options for fixing this:
Serve your data from the same host you're making the request from.
Use JSONP instead of JSON.