Support Forums

Full Version: Complicated HTML Problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
(12-19-2009, 02:49 PM)Master of The Universe Wrote: [ -> ]Ajax would do it, http://www.w3schools.com/Ajax/Default.Asp

Could you give me an example of some code I would use?
(12-19-2009, 03:08 PM)Rob Wrote: [ -> ]Could you give me an example of some code I would use?

So here you go, there is a php script that loads the content of a given website, in this case it's a google.com

PHP Code:
<?php

$content 
file_get_contents("http://www.google.com/");

$matches null;

preg_match_all("/<title>(.*?)<\/title>/"$content$matches);

echo 
$matches[1][0];

?>

The preg_match function will search for the title of the loaded content and it will echo it
Now the ajax, the code is taken from w3 and I edited few lines...

Code:
<html>
<body>

<script type="text/javascript">
function ajaxFunction()
{
var xmlhttp;
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  // code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4)
  {
  document.getElementById("content").innerHTML=xmlhttp.responseText;
  }
}
xmlhttp.open("GET","extern.php",true);
xmlhttp.send(null);
}
</script>

<div id="content" onclick="ajaxFunction();">
a
</div>

</body>
</html>


When you click on the div, the ajaxFunction will load extern.php.... and update the inner html of the div.
(12-19-2009, 03:14 PM)Master of The Universe Wrote: [ -> ]reserving a place... just a sec

Sorry to go a little off topic here, but, @ MotU, "reserving a place....just a sec." Lol.
(12-19-2009, 03:14 PM)Master of The Universe Wrote: [ -> ]reserving a place... just a sec

Okay thanks.
(12-19-2009, 03:15 PM)Grizzly Wrote: [ -> ]Sorry to go a little off topic here, but, @ MotU, "reserving a place....just a sec." Lol.

Well I guess he was letting me know that he was working on it. I appreciate the heads up.
Yeah, I didn't mean to disappear on you like that. I had to take my wife to the hospital a couple hours ago because she has appendicitis and I was on the phone with her while she was letting me know what the doc's said. But, he appears to have it all under control.
(12-19-2009, 03:33 PM)Grizzly Wrote: [ -> ]Yeah, I didn't mean to disappear on you like that. I had to take my wife to the hospital a couple hours ago because she has appendicitis and I was on the phone with her while she was letting me know what the doc's said. But, he appears to have it all under control.

Oh sorry to hear that. Glad everything's under control though.
(12-19-2009, 03:15 PM)Grizzly Wrote: [ -> ]Sorry to go a little off topic here, but, @ MotU, "reserving a place....just a sec." Lol.

Yeah lol it didn't went as I thought, I needed a min to edit that post, but I had to go to, so I couldn't update it....
But we want to have quality posts, so I updated it now...
It's 05:47am now and I'm finally home tired as hell

I'm sorry too for disappearing...
are you trying to include a whole page(text file/html/etc) into an area?

use this http://www.hackforums.net/showthread.php?tid=99831
Thanks for the help guys, I don't think this is going to work out as I wanted though.
Pages: 1 2