PHP JavaScript AJAX

Like this blog? Consider exploring one of our sponsored banner ads...

Using Prototype, AJAX is extremely easy. Following is a small function to perform one of the most basic AJAX funstions, to replace the contents of a div element. Modify the function to have the correct php file to hit and loading gif, then simply pass in the div you want to update and the params you want to send to the php file. You can get great loading gifs from www.ajaxload.info .

[js]
function getHTML(div,params){

var url = ‘http://www.bradino.com/inc/ajax.php’;
$(div).innerHTML=’‘;
var myAjax = new Ajax.Updater( {success: div}, url, { method: ‘post’, parameters: params});

}
[/js]


About this entry