Getting Started with Ajax
June 23, 2005
Using xmlOpen(...) in an Example
The following is a fragment of code from pages/part1.html
demonstrating proper use of
The
xmlGet(...)
01 <body>
02 Click <a href="javascript: xmlGet('notes.xml', notesResponseHandler);">here</a>
03 to get the contents of <code>notes.xml</code> from the server.
04 <br />
05 <div class="notes" id="notesSection"></div>
06 </body>
xmlGet(...) can be called from anywhere Javascript is executed. In this
example, it is called from the href attribute of the anchor tag on
line 2.
We pass 'notes.xml' as the url parameter and
notesResponseHandler as the responseHandler parameter. We will
discuss notesResponseHandler() later, but for now it suffices to know that
it is the Javascript function that will handle the server's response and place data
into the 'notesSection' DIV
(line 5).
The url passed to
xmlGet(...) is a relative URL and will be retrieved from the same server that's
hosting part1.html.



