Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Closed Thread
 
LinkBack Thread Tools Display Modes
Old 17-12-2007, 03:41 PM   #1 (permalink)
Wahahaha~!
 
Faun's Avatar
 
Join Date: Dec 2006
Location: Pune/there
Posts: 7,675
Default A Newbie Tutorial to AJAX


Here is a simple tutorial for AJAX aspirants who just want to know how ajax works wihout digging into server side programming.

Needed Tools:
  • Text Editor (preferably Notepad++)
  • IE 6+, Firefox 0.8+.
Needed Files:
  • A html file (named as ajax.html)
  • A text file (named as sample.txt)
Make the html file named anything.
  • I hav named it "ajax.html"
Quote:
<html>
<head>
<title>
A Simple Ajax Example
</title>
<script type="text/javascript">
<!-- Older browser hidden soce
function doAjax(fileToRead){
var request = null;
var str;
if(window.XMLHttpRequest)
{
str = "inside XMLHttpRequest"
document.getElementById("displayDiv").innerHTML= str;
request = new XMLHttpRequest();
}
else if(window.ActiveXObjexct)
{
str = "inside ActiveXObject"
document.getElementById("displayDiv").innerHTML= str;
request = new ActiveXObject("Miscrosoft.XMLHTTP");
}


if (request)
{
request.open("GET",fileToRead);
request.onreadystatechange = function()
{
if(request.readyState == 4)
{
str = str + " <br> yahoo ajax xompleted" + "<br> content of file sample.txt is:<br>" + request.responseText;
document.getElementById("displayDiv").innerHTML=st r;
}
}
request.send(null);
}
else
{
alert("you must upgrade your browser!");
}
}
-->
</script>
</head>
<body>
<input type="button" value="make ajax request" onClick="doAjax('sample.txt');return true;">
<div id="displayDiv"></div>
</body>
</html>
Now make another file "sample.txt" from where the data will be fetched to html page.
Let the content be anything u want.
  • Here are mine "sample.txt" contents:
Quote:
u got the ajax request completed
with the data from this file named
sample.txt
Working:
  • open "ajax.html" in browser
  • when u click on "make a ajax request" button the content of file "sample.txt" will be fetched without a reload of webpage.
  • thats it.
Explaination:
Will provide an in-detail explaination soon as am havin exams now
__________________
Blog | Flickr | Battlelog
Spoiler:
Asus Z68 V-Pro|i5 2500k|TRUE Black|Ripjaws X|U2311H|N560GTX|D7000|XONAR STX|RE272|RE0|CC51|XE200PRO Walnut| TD II V2| Ultraphile|N5800

Mono

Last edited by Faun; 17-12-2007 at 04:15 PM.
Faun is online now  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 17-12-2007, 08:40 PM   #2 (permalink)
Be CoOl rAp RuLeZ !!!
 
krates's Avatar
 
Join Date: Feb 2007
Posts: 1,968
Default Re: A Newbie Tutorial to AJAX

well good one for newbie and ajax by it's name and work looks dificult but it is to o easy
__________________
iPhone 3G 16GB + Samsung I450 + Sennheiser CXL 400 + PSP Phat + Samsung NC10 :D

Previous phones: N73ME , W810I , Asus P320
krates is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
AJAX tutorial rohan Programming 37 16-06-2009 10:11 AM
Newbie Tutorial: How to type a message in ur desired language using Microsoft word? sridatta Tutorials 30 05-10-2007 01:47 PM
Newbie Tutorial: Setting Up options in TuneUp Utilities to boost your PC sridatta Tutorials 5 18-11-2006 12:02 AM
What is AJAX support Aijaz Akhtar QnA (read only) 2 25-10-2005 03:29 AM

 
Latest Threads
- by Charan
- by Sarath
- by clmlbx

Advertisement




All times are GMT +5.5. The time now is 12:45 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2