/* with mootools */
window.addEvent('domready',function() {
/* fetch elements */
$$('form.follow-form').each(function(form) {
/* stop form event */
form.addEvent('submit',function(e) {
/* stop event */
if(e) e.stop();
/* send ajax request */
var i = form.getElement('i');
new Request({
url: 'twitter-follow.php',
method: 'post',
data: {
followID: form.getElement('input').value
},
onRequest: function() {
i.addClass('active');
},
onSuccess: function() {
var button = form.getElement('button');
button.setStyle('display','none');
new Element('span',{
html: '<SPAN></SPAN>Following!',
'class': 'following'
}).inject(button,'after');
},
onComplete: function() {
i.removeClass('active');
}
}).send();
});
});
}); |