Imagine that you have a file on the server that contains data that you'd like to use on a web page. We will devise a way to get that data, and then display it on our web page without requiring a page refresh.
Create an HTML document that will hold our remote data, and save it with the file name of
mydata.html
.In
mydata.html
, put in some HTML content. This is what I used, but feel free to put your own valid HTML markup:<p>This is some <strong>remote</strong> data that I requested.</p>
Next we need an HTML document that will be our web page that requests the data from
mydata.html
. Create this HTML document and place it in the same location asmydata.html
.In our web page HTML document, we place an
<a>
element that will serve as the trigger for making our Ajax request. This document also has a div where we will place the data we get frommydata.html
; give this div an ID ofcontent-holder
. In the HTML document, we use the following...