Access server-side Java code via Ajax

We are trying to access our server-side Java code via Ajax, so that we can call some of our server methods on certain browser actions (i.e. loading/unloading) but unfortunately the code doesn't seem to be connecting up.  At the moment, we have a server side function which will write out to a file, and we want to access this.  The code is in a file called admin, and the code to access it is as follows:

var path= "http://ourServerIP/pathToOurClassFiles";
var url= path +"/admin?act=runningTime";
var xmlHttp;
if (window.ActiveXObject) {
      xmlHttp  = new ActiveXObject("Microsoft.XMLHTTP");
} else if (window.XMLHttpRequest) {
      xmlHttp = new XMLHttpRequest();
} else {
      return(null);
}
xmlHttp.onreadystatechange=function()
{      
  if (xmlHttp.readyState==4 && xmlHttp.status==200)
  {
        if(xmlHttp.responseText!="")
        document.getElementById("running_time").innerHTML=": "+xmlHttp.responseText;
  }
}
xmlHttp.open("GET",url,true)
xmlHttp.send(null)

The html file calling this script resides on a different server from the server-side java files, so we can't have a relative path.  Is the basic logic of this code correct, or is something missing to make this code fully connect - if so, what is it?
anotherfnAsked:
Who is Participating?
 
leakim971PluritechnicianCommented:
0
 
leakim971PluritechnicianCommented:
>Is the basic logic of this code correct, or is something missing to make this code fully connect - if so, what is it?

Why it don't work : http://en.wikipedia.org/wiki/Same_origin_policy

You may use a proxy on the server delivering the page doing the ajax call to load the page on the other servers
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.