newbreed65 Posted August 5, 2009 Share Posted August 5, 2009 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 = ""; } } Quote Link to comment https://forums.phpfreaks.com/topic/169003-httpopening-a-page-on-a-different-server/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.