AJAX -Simple to implement

Hello,
I found Prototype.js http://www.prototypejs.org/download is a nice tool for implementing ajax. You could use it in any framework. Just download the file, and load that by <script src=””>. Then implement the following code
A typical example to how to use ajax:
Ajax.Request is the main function here.
<script type=”text/javascript” language=”javascript”>
function myProcess(action)
{
url = “”;
url = url + ‘startPHP.php’;
pars = ‘action=’ + action;
myAjax = new Ajax.Request(url, {method: ‘get’, parameters: pars, onLoading: showLoad, onComplete: showResponse, onError: showError} );
}
function showLoad()
{
$(‘content’).innerHTML = ” What you want to show”;
}
function showResponse(response)
{
var newData = response.responseText;
$(‘content’).innerHTML = newData;
}
function showError(ale)
{
alert(ale);
}</script>

About mahmud ahsan

Founder And Lead Programmer at iThinkdiff.net

, ,

4 Responses to AJAX -Simple to implement

  1. Naseer Ahmad Mughal August 21, 2008 at 1:19 pm #

    nice class.
    Can you also post its tutorials too?

  2. mahmudahsan August 21, 2008 at 3:52 pm #

    I used this code long times ago. However, JQuery is far better than prototype.js or YUI js framework. So, you could use JQuery for ajax or other javascript tasks.

  3. Vinayak December 20, 2010 at 9:01 am #

    can you suggest the trick to use ajax in blogger or blogspot sites….how can this used in those sites….

    ProBogBooster

  4. Virendra Rajput February 13, 2012 at 12:34 am #

    Prototype seems to be easy to learn !