just like my previous script, but with a neat support for <form> tags.
As previous script did, just add TARGET attribute with the ID of your AJAX target.
window.onload=function(){
Event.observe(document.body, ‘click’, function(event) {
var element = Event.element(event);
if (’A’ == element.tagName){
if ($(element.target) != undefined){
new Ajax.Updater(element.target,element.href,
{method:”post”,evalscripts:true})
Event.stop(event);
}
}
});
formz=document.getElementsByTagName(”form”);
for (i=0;i<formz.length;i++){
if ( formz[i].target!=undefined && formz[i].id!= “”){
el=formz[i].id
tar=formz[i].target
Event.observe(formz[i].id, ’submit’, function(event) {
$(el).request({
onSuccess: function(t) {
$(tar).update(t.responseText);
}
})
});
}
}
}
