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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
leakim971PluritechnicianCommented:
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
AJAX

From novice to tech pro — start learning today.