First consider this: StackoverFlow link.
Here, Ajax is used to open an Xhttp channel to the server, and send some data to the php script file using post method. I have a perl script file inside CGI-bin, but that should work too.
I want to send the data via Javascript to the Perl script, and receive it back without the page refreshing, so I did this:
Javascript:
var basepath = "localhost";
var req = new XMLHttpRequest();
req.open("POST", basepath+"/perlweb/lox.pl", false);
req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
req.send("script="+this.script);
req.onreadystatechange = function(){
// execute this when ready state changes, i.e. server responds
if (req.readyState == 4 && req.Status == 200) {
// we got what we wanted
console.log(req.responseText);
}
}
lox.pl
is my script name. It is in /perlweb under localhost.
I have created this file in the same place under the name test.pl:
#! /path/to/perl
print "Content-type: text/plain\n\n";
print "it now works\n";
Calling this with /localhost/perlweb/test.pl
produces the expected output. So I am thinking perl is ready as well.
Now, back to the javascript I have two things:
I have this warning :
Synchrone XMLHttpRequests am Haupt-Thread sollte nicht mehr verwendet werden, weil es nachteilige Effekte für das Erlebnis der Endbenutzer hat. Für weitere Hilfe siehe http://xhr.spec.whatwg.org/
Translates to : Synchronous XMLHttpRequest in main thread should not be used any more, because it can have sustainable effects (?? sic) for the final result of the end users.
I want to get rid of this, but I am not aware, where to start. Looking up the link xhr.spec.whatwg.org is confusing me. That seems like a full specification document.
Could anyone please simply point me to what I am supposed to do?
And I have this error:
NS_ERROR_DOM_BAD_URI: Access to restricted URI denied
Although the file exists in my own machine (because the file exists in my own machine, I am assuming that I am not going to hit the CORS issue).
What is then causing the problem?