Ajax

sort by: newest oldest
January 6, 2009 at 07:06 pm - by error404 (2 Posts)
icon

 Does anyone know ajax or a good place to learn ajax other than w3 schools.

I need to get text files to load into a section of my website called "colTwo".

Or html files. There is going to be at least 5 of these pages or text files if that makes a difference.

September 21, 2009 at 10:23 am - by Boltgog (1 Posts)
icon
If you know PHP and JavaScript, then it shouldn't be too hard to learn AJAX. I would suggest either getting a copy of Building a Website with Ajax by Larry Ullman (I bought it and it has tought me quite a bit).
April 27, 2009 at 08:27 pm - by Pancake (6 Posts)
icon

If you're including a file from PHP, it's probably best that you use: echo file_get_contents("file.txt"); simply because using include() executes the contents of the file.

April 19, 2009 at 01:26 pm - by Cypy (4 Posts)
icon

As Broopet and Coder already mentioned, you do not need Ajax to load text files into your website. Ajax is a way to send http requests asynchronously, after your website has already been loaded by the user. If you simply want these text files to be loaded to "colTwo" as the page itself loads, use PHP. This is how it works:

 

  • create a PHP file (ex. index.php)
  • in the PHP file, write out all your website code, but in the place where you want to include a file, write  <?php include("filename.txt"); ?>
  • if you want to include multiple files, you can do that too: <?php include("filename.txt"); include("anotherfile.txt"); include("lastfile.txt"); ?>
Let me know if you want these files to appear dynamically—when the user clicks a button for instance—and I'll help you with Ajax.

 

January 18, 2009 at 11:04 am - by broopet09 (6 Posts)
icon

PHP is certainly an option, and potentially easier than AJAX, but it doesn't have the nice dynamic feel of the page populating before your eyes. I would check out jQuery or one of the other AJAX frameworks. I know that jQuery has something along the lines of Ajax.load() which will send off an xmlHttpRequest to get the page asynchronously (dynamically) and then put the results wherever you want them. jQuery has some pretty good tutorials if I recall correctly.

-peter

January 9, 2009 at 10:30 am - by coder78 (1 Posts)
icon

I would use php.  There are plenty of php functions that will open text files and include them, or if they are html files, the include function will do it for you.