Mootools

January 6th, 2009

Code ini digunakan untuk membantu dalam menerapkan mootools sebagai Ajax class. Loader image nya bisa di download di sini http://www.ajaxload.info/

Code buat javascript nya

  function ajax_get(url, target) {
    $(target).empty().addClass('ajax_loading');
  	new Ajax(url, {
  		method: 'get',
      update: target,
      onComplete: function() {
      	$(target).removeClass('ajax_loading');
      }
  	}).request();
  }
  function ajax_post(url, form, target) {
    // $(target).empty().addClass('ajax_loading');
    $(target).empty().addClass('ajax_loading');
    // Disabled button
    $("searchButton").disabled = true;
    new Ajax(url, {
  	  postBody:$(form),
      update: target,
      onComplete: function() {
        $(target).removeClass('ajax_loading');
  		  $("searchButton").disabled = false;
  		  document.location = "#searchAnchor";
      }
    }).request();
   	return false;
  }

Ini code buat CSS nya

.ajax_loading {
	padding: 20px 0;
	background: url(/jibunshi/CI/images/spinner.gif) no-repeat top;
}

Credits goes to Eriaji

Share
  1. No comments yet.
  1. No trackbacks yet.

Switch to our mobile site