Username:
Password:
Remember me:
Register

Back to forum: Web Programming (HTML, JS, CSS, PHP, MySQL)


Search forums via Google


0 Users appreciate this thread.

A Sample Ajax Script
Started by ryanb000977
(2014-06-11 20:19:50)
ryanb000977 (2014-06-11 20:19:50)
I've had a few requests for something like this.

Source Code
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Sample Ajax</title> <script type="text/javascript"> function updateArea() { var ajaxRequest; if (window.XMLHttpRequest) { ajaxRequest = new XMLHttpRequest(); } else { ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP" ); } ajaxRequest.onreadystatechange = function() { if (ajaxRequest.readyState == 4 && ajaxRequest.status == 200) { document.getElementById("area" ).innerHTML = ajaxRequest.responseText; } } ajaxRequest.open("GET","getPage.php",true); ajaxRequest.send(); } </script> </head> <body onload="setInterval('update()', 5000)"> <div id="area"> <p>Before</p> </div> </body> </html>


Page 2

Source Code
<p>After</p>


If there is issues, leave a comment!


This post has been edited one or more times, the last time was:
2014-06-12 03:20:25

carlos11 (2014-06-13 09:04:57)
Issue#1: Too complicated. Dumb it down.
Language is a tool for efficient communication. The internet is a tool for fast communication. Do not defy both intents by posting incoherent writing.
ryanb000977 (2014-06-13 21:55:37)
@carlos11 You obviously don't program web sites.

This post has been edited one or more times, the last time was:
2014-06-14 04:56:01

TheAlexRider (2014-06-13 22:35:27)
Sticky Request



Useful for new coders (Im just lookin through all threads)
SPCOxion (2014-06-19 05:13:23)
@carlos11
This is AJAX.
Unless you're using a library, it doesn't get any simpler than this.
GuitarBoy (2014-06-27 18:03:06)
AJAX is not a library. The XMLHttpRequest object is just that--an object that contains property values and methods.

A library is an abstraction of code that combines one or more core features of a language to make future code easier, simpler, and maybe even more efficient.
http://m.ajango.org - Ajango
New social networking website coming this year! Check for updates frequently!

Ajango Forum Thread
SPCOxion (2014-06-27 18:14:50)
@CoolApps
no, it isnt
do you need to do some stuff like <script src='ajax.js'></script> to use it?
no
no you dont
SPCOxion (2014-06-29 08:16:21)
Yes, it does.

If it's something you can include in files to make tedious tasks faster, it's a library.

Hell, you could even technically make yourself a 'mini-library' for your own needs.
SPCOxion (2014-06-30 16:07:27)
Yeah.

Most people probably do that in the first place, just to make things easier for themselves.

By the way, if you really want to use a $displayIP on your website, you should look into proxy detection, accurate IP guesses, etc.
Kouta (2014-09-10 02:32:25)
If you think everything above is too hard, try mircoAjax, a tiny Ajax Library created by Stefan Lange-Hegermann.

<script src="http://microajax.googlecode.com/svn/trunk/microajax.js"></script>

<script>
microAjax("/resource/url", function (res) {
alert (res);
});
</script>

If this doesn't help you, you are on your own!
~Pro64TM

GuitarBoy is correct when he mentioned about Ajax not being a library.

This post has been edited one or more times, the last time was:
2014-09-27 13:56:21

 

Log in to submit a comment

This topic's ID: 71316

Back to forum: Web Programming (HTML, JS, CSS, PHP, MySQL)




Total registered users: 8321
New registered users today: 7
Newest registered user: ElegantVulpes

©  Copyright 2026 3DSPlaza. All Rights Reserved