lynxus Posted November 28, 2008 Share Posted November 28, 2008 Hi guys. I have a script on a webserver , lets say 10.0.0.2 my main page is on 10.0.0.1/index.html Does anyone know how i can get the data from the script on the html page? Im assuming maybe javascript on the html page could go look for the output of output.php ? I hope this makes sense? Thanks G Link to comment https://forums.phpfreaks.com/topic/134667-show-output-of-php-script-in-a-div/ Share on other sites More sharing options...
revraz Posted November 28, 2008 Share Posted November 28, 2008 CURL? Link to comment https://forums.phpfreaks.com/topic/134667-show-output-of-php-script-in-a-div/#findComment-701177 Share on other sites More sharing options...
Mchl Posted November 28, 2008 Share Posted November 28, 2008 You're making easy things difficult... Yes you can use javascript to load output of php script into div - this technology is called AJAX You can also rename your index.html to index.php and put your php code into it. That's easier but might not be exactly what you're looking for (hard to say without more information) Link to comment https://forums.phpfreaks.com/topic/134667-show-output-of-php-script-in-a-div/#findComment-701178 Share on other sites More sharing options...
corbin Posted November 28, 2008 Share Posted November 28, 2008 You're making easy things difficult... Yes you can use javascript to load output of php script into div - this technology is called AJAX You can also rename your index.html to index.php and put your php code into it. That's easier but might not be exactly what you're looking for (hard to say without more information) It's different hosts, so AJAX won't work ;p. Link to comment https://forums.phpfreaks.com/topic/134667-show-output-of-php-script-in-a-div/#findComment-701198 Share on other sites More sharing options...
Mchl Posted November 28, 2008 Share Posted November 28, 2008 Ah... missed it That changes things quite a lot Link to comment https://forums.phpfreaks.com/topic/134667-show-output-of-php-script-in-a-div/#findComment-701210 Share on other sites More sharing options...
lynxus Posted December 1, 2008 Author Share Posted December 1, 2008 OK ive managed this, but it doesnt work when i run this script on another machine other than the one with the PHP script on.. Any ideas how i can get round this ? This has been driving me mad for about 3 months now and really starting to bugger up my plans. Essentially what im trying to do is have a user put some small code on their site with someting like ID=1 in their code. When a user visits it will goto my php script on another server. the script will then output some html that gets placed in the div on the end users machine. For the life of me i cant get this working on any other machine than the one that the php script is actually on. <html> <body onload="ajaxContentUpper();"> <script language="javascript" type="text/javascript"> <!-- function ajaxContentUpper() { var ajaxRequest; try { // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); } catch (e) { // Internet Explorer Browsers try { ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { // Something went wrong alert("Your browser broke!"); return false; } } } // Create a function that will receive data sent from the server ajaxRequest.onreadystatechange = function() { if(ajaxRequest.readyState == 4) { var ajaxDisplay = document.getElementById('TestContent'); var result = ajaxRequest.responseText; if (result == 'expired') { window.location = '/'; } else { ajaxDisplay.innerHTML = result; reSizeLeftRight(); } } } ajaxRequest.open("GET", "http://212.125.94.168/ajax/gimme.php", true); ajaxRequest.send(null); } //--> </script> <div id = "TestContent"> </div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/134667-show-output-of-php-script-in-a-div/#findComment-703083 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.