I have an JavaScript(AJAX) code which takes data from an php file (Pagerank Script which returns an variable $prr=6 where 6 is pagerank of the verified link) using GET and transform it in xml file to become handable for java.
This is the function wich creates Xml Http Request:
var xmlHttp = createXmlHttpRequestObject();
function createXmlHttpRequestObject(){
var xmlHttp;
if(window.ActiveXObject){
try{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}catch(e){
xmlHttp = false;
}
}else{
try{
xmlHttp = new XMLHttpRequest();
}catch(e){
xmlHttp = false;
}
}
if(!xmlHttp)
alert("Nu pot crea XML!");
else
return xmlHttp;
}
This is the process function:
window.onload = function process(){
if(xmlHttp.readyState==0 || xmlHttp.readyState==4){
link = encodeURIComponent(value = 'google.ro');
local = '/v1.php?verifica=';
xmlHttp.open("GET", local+link,true);
xmlHttp.onreadystatechange = handleServerResponse;
xmlHttp.send(null);
}else{
}
}
And this is Handle the response of the server:
function handleServerResponse(){
if(xmlHttp.readyState==4){
if(xmlHttp.status==200){
xmlResponse = xmlHttp.responseXML;
xmlDocumentElement = xmlResponse.documentElement;
message = xmlDocumentElement.firstChild.data;
document.getElementById("Raspuns").innerHTML = message;
}else{
alert("Probleme cu datele returnate de server!");
}
}
}
I have an document writer for generating id tag for getElementById()
document.write('<script type="text/javascript" src="http://verificapagerank.32biti.com/java/verifica.js"></script> <div id="Raspuns"></div>');
This is the code for including javascript file:
<script type="text/javascript" src="http://verificapagerank.32biti.com/java/calculator.js"></script>
All is fine until i put the code on external site! On external files I get alert error from handleServerResponse()
`Probleme cu datele returnate de server!`