Saturday, 28 February 2015

xmlhttp.open fails when switching from http to an https (SSL) call to a simple perl script



I have the following javascript running using a Win7 IE client that works fine when http is used but not https



<script type="text/javascript">
function checkloginform() {
if (window.XMLHttpRequest) {
xmlhttp=new XMLHttpRequest(); // code for IE7+, Firefox, Chrome, Opera, Safari
} else {
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); // code for IE6, IE5
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
var y = xmlhttp.responseText;
document.getElementById("memo").innerHTML = y;
} else {
document.getElementById("memo").innerHTML =
'Error: '+ xmlhttp.readyState + ' ' + xmlhttp.status;
}
}
xmlhttp.open("GET","/login/login.pl",true);
xmlhttp.send();
}
</script>


if I change



xmlhttp.open("GET","/login/login.pl",true);


to



xmlhttp.open("GET","http://ift.tt/1BNurPB",true);


I get nothing back and no status errors?


If I access the url directly from the same browser it does return the expected output.


here is the server side login.pl



#!/usr/bin/perl

MAIN:
{
print qq~content-type: text/xml\n\TEST\n ~;
exit;
}

No comments:

Post a Comment