![]() |
| | #1 (permalink) |
| Junior Member Casual Browser | AJAX allows you to make a call to an http server (typically an RSS feed or a webpage), get it’s content and load them into your existing page without having to refresh the whole page. This means that services like email don’t have to reload the whole page everytime you click a message, saving on bandwidth (loading the header/footer all over again) and making things more efficient. Code: <script type="text/javascript">
function loadurl(dest) {
try {
// Moz supports XMLHttpRequest. IE uses ActiveX.
// browser detction is bad. object detection works for any browser
xmlhttp = window.XMLHttpRequest?new XMLHttpRequest():
new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {
// browser doesn't support ajax. handle however you want
}
// the xmlhttp object triggers an event everytime the status changes
// triggered() function handles the events
xmlhttp.onreadystatechange = triggered;
// open takes in the HTTP method and url.
xmlhttp.open("GET", dest);
// send the request. if this is a POST request we would have
// sent post variables: send("name=aleem&gender=male)
// Moz is fine with just send(); but
// IE expects a value here, hence we do send(null);
xmlhttp.send(null);
}
function triggered() {
// if the readyState code is 4 (Completed)
// and http status is 200 (OK) we go ahead and get the responseText
// other readyState codes:
// 0=Uninitialised 1=Loading 2=Loaded 3=Interactive
if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
// xmlhttp.responseText object contains the response.
document.getElementById("output").innerHTML =
xmlhttp.responseText;
}
}
</script>
Code: <div id="output" onclick="loadurl('/resume/resume.txt')">click here to load my resume into this div</div>
Of course you are going to have to create the page to load. you can use html, php, ect pages as well with formatting rather than a txt file. enjoy! many more to come Last edited by danielmichel; 11-27-2006 at 07:18 PM. |
| | |
| | #4 (permalink) |
| Senior Member Fanatic | Seco, it might be worth you writing an article on what AJAX is... not really show code but talk about the languages that comprise it, it's pitfalls and advantages and such. I was going to write it, but I'm not fond enough of AJAX to be writing tutorials, so I am offering you the chance to write it. If you don't want to, just tell me and I'll write it. Take Care, and good little tutorial. _Michael |
| | |
| | #7 (permalink) |
| Junior Member Casual Browser | sofar i havent had any issues concerning blocking, if you have javascript disabled why are you on the web in the first place, since a large percentage of sites use it vastly now. but activeX isnt a concern, i havent checked it out on IE7 though so i dont know.
__________________ Seco --- Yes, I play a Fretless Bass :) |
| | |
| | #8 (permalink) |
| Junior Member Casual Browser Join Date: Apr 2006 Age: 39
Posts: 23
![]() | AJAX - an acronym for Asynchronous Javascript And XML - really is a revisitation of fairly old technologies and being put to great use. What is interesting about most of the examples and discussions about AJAX that I have run across is most folks talk about what the components of AJAX can do or how they work under the hood, but few discuss the larger picture of how one goes about creating an AJAX driven web application. What I would really like to see is how this translates to the design phase of a site. Is it enough to just go through classic interface design and then retrofit AJAX into components well suited for it? I have found that it is not always easy to transform sites into AJAX driven sites, but rather much easier when you can start from scratch. Does anyone have ideas about how best to manage the design process of both a rebuild from scratch and an adaptation of the technology to existing structure? |
| | |
| | #9 (permalink) |
| Junior Member Newb Join Date: Nov 2006
Posts: 12
![]() | Correct if I'm wrong but I have seen many relatively old javascripts snippets going now under the AJAX category today. Does this mean that AJAX is just a term to redefine something already existing to continue its development and implementation? |
| | |
| | #13 (permalink) |
| Junior Member Join Date: May 2009
Posts: 1
![]() | Thank you so much! I've spent about six months searching for AJAX tutorials, and I've read more than hundreds of tutorials, but none of them was clear enough to teach me. This one was the best out of hundreds that I've read! You have no idea how grateful I am! Thank you so much! //Feelay |
| | |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| About Ajax | manju | Website Programming | 1 | 03-26-2009 08:56 AM |
| Simple website templates... | Brighteyes | Website Design & Layout | 1 | 12-28-2006 06:03 PM |
| What is AJAX? | melissajean85 | Software Development | 1 | 11-26-2006 07:35 PM |
| Simple, quick preloader. | seco | Tutorials | 2 | 10-28-2006 07:28 AM |