|
||||||
| Tutorials Programming Tutorials - Post your tutorials here! |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||||
|
AJAX is one of the newest and post popular technologies. AJAX [Asynchronous JavaScript and XML] allows you to send a request to the server and view the results without having to refresh the page. This enables you to create a more "windows-like" applications. This tutorial will explain the basics of AJAX.
The heart behind AJAX is the JavaScript XMLHttpRequest object. Since all browsers react differently to JavaScript creating a cross browser application can be difficult. The core code I always use is below: JavaScript Code:
This code works with FireFox, Internet Explorer, Opera, and many more. To send information to a server, I use the open() and send() functions. Open accepts three parameters, the "connection" type (either POST or GET), the file location, and a boolean value which determines whether the connection should be asynchronous. The send() function "sends" the request. The code will look like this: JavaScript Code:
Now before you actually submit data to a file you should actually make sure data needs to be submitted, and we do that by making sure the "state" was changed. Which might look like this: JavaScript Code:
The ready state has five "states": 0, 1, 2, 3, and 4. Ill tell you more about them in future tutorials when they are needed, but for this tutorial all we are concerned with is state four, which means the request is complete. So essentially what the code above does, is - if the request was complete, the web page is going to update the, lets say input box, named elementName inside the form named formName with the response from the server - which is a value echoed plain text. For example if ajax.php had this code: PHP Code:
HTML4Strict Code:
Assuming you setup everything properly, each time you type something in the "anything" input box the "elementName" input box should update with the current time.
__________________
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. | To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. | To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. | To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. | To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall Last edited by John; 09-23-2007 at 10:24 PM. |
| Sponsored Links |
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Considering Ajax, Part 1: Cut through the hype | Ronin | JavaScript and CSS | 0 | 12-13-2006 02:36 PM |
| Myth-Busting AJAX (In)security | Jordan | AJAX | 1 | 12-03-2006 01:21 PM |
| AJAX Evolved | Jordan | JavaScript and CSS | 0 | 09-09-2006 01:12 PM |
| More AJAX Resources | NeedHelp | JavaScript and CSS | 2 | 07-13-2006 12:57 PM |
| Anybody use Ajax? | Dan | JavaScript and CSS | 9 | 07-05-2006 03:25 PM |
| Xav | ........ | 1097.16 |
| MeTh0Dz|Reb0rn | ........ | 986.37 |
| morefood2001 | ........ | 850.04 |
| John | ........ | 841.93 |
| WingedPanther | ........ | 684.54 |
| marwex89 | ........ | 638.26 |
| Brandon W | ........ | 492.36 |
| chili5 | ........ | 292.12 |
| Steve.L | ........ | 188.37 |
| orjan | ........ | 187.41 |
Goal: 100,000 Posts
Complete: 79%