Send Ajax request to the server
Task description
Displaying the server's time or user's IP in a HTML element by clicking on links.
Working example
Clickable links
Server response
The server's response will appear here
Implementation steps
- Create links and a DIV for the result of the requests.
- Make the links call a PlainAjax request when clicked
- In the PlainAjax request configure what server-side script to call and where to put the server response
The HTML Code
<a onclick="plainajax.request('respurl: servertime.php; resultloc: myresult;')">Display server time</a>
<a onclick="plainajax.request('respurl: userip.php; resultloc: myresult;')">Display user's IP</a>
<div id="myresult"></div>
Note: the server-side scripts (defined in respurl attribute) can be implemented in any language, java, ruby, php, etc..
Check another example on how to