Jump to content

Recommended Posts

Hiya everyone

 

I'm currently working on a project where I need to be able to log certain information by Ajax running a php page behind the scene that logs the information in a database. I can get this working fine when both verbiage's are located on one domain server but I'm having difficulty getting it to work when there on separate servers...

 

I'm ab it of a noob when it comes to Ajax and got a feeling I'm trying to wrong thing when your need to interact with different servers, just a lil unsure were to go now

 

Below is the code i have currently

 

function getXMLHTTPRequest() {
			try {
			req = new XMLHttpRequest();
			} catch(err1) {
			  try {
			  req = new ActiveXObject("Msxml2.XMLHTTP");
			  } catch (err2) {
				try {
				req = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (err3) {
				  req = false;
				} 
			  } 
			}
			return req;
			}

			var http = getXMLHTTPRequest();

			function getServerText() {
			  var myurl = 'http://www.ftp5.dns-systems.net/~guardhog/test.php';
			  myRand = parseInt(Math.random()*999999999999999);
			  
			  var client = "&client=123456"
			  var modurl = myurl+"?rand="+myRand+client;

			  http.open("GET", modurl, true);
			  http.onreadystatechange = useHttpResponse;
			  http.send(null);
			}

			function useHttpResponse() {
			   if (http.readyState == 4) {
				if(http.status == 200) { 
				  var mytext = http.responseText;
				  document.getElementById('myPageElement').innerHTML = mytext;
				}
			  } else {
			  document. getElementById('myPageElement').innerHTML = "";
			  }
			}

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.