Happy TutorialsHow many times have tutorials said that! Well, i'll try and make this as simple as possible.
Ajax is a way of loading content into a page without reloading the whole page. It makes things quick, and allows more interactive page and give you many more options for user interface designs
The sequence of events (in this example)
First we have to create the javascript function, this can be anywhere on your HTML course, but it usual in the between <head> </head> sections to keep your page itself clear of code
| Javascript | Human Person Language |
<script type="text/javascript">
var http = false;
if(navigator.appName == "Microsoft Internet Explorer") {
} else {
}
}
}
} </script> |
Tell the browser that this part is javascript code
This part does some fancy stuff, don't worry what it means, it just sets up the javascript stuff so it can go and get information from another page
Start a function called loadInformation
This is the important bit! It opens up the page 'newpage.html'
This part waits until javascript has opened up the page
And sets the content of a div called 'feedback' to the content of the PHP page |
| HTML Text Input Form Field | Human Person Language |
<a href="#" onclick="loadInformation(); return false">Load Some Information</a> |
This is just a simple link. The 'onclick=loadInformation()' bit means that, when some clicks on the link, it runs the javascript function called loadInformation.
The 'return false' bit just stops the page scrolling to top every time you click on the link |
| HTML Page |
On this html page, you can put what ever you want! |
Save this file as newpage.html.
Try it, it should all work!