Introducing AJAX Get API

I've been itching to contribute back to the Drupal community for some time now. Recently, I committed two sandbox projects, one of which is the AJAX Get API module.  The idea is to create a simple way to request Drupal objects like Nodes, Forms, Views, and Users via AJAX and return HTML or JSON formats.  I haven't been able to find a tool like this so I developed it with some help of my coworkers.  We've incorporated this module into our latest project, which boasts a pretty slick application-like AJAX interface.  We get forms, submit data, and refresh views thanks to this module and the exist Ajax module, which we use for submiting the data via ajax.  Here's an example.



 // Code from mymodule.js                  

// Attach click event to button to dynamcally load form into a jQueryUI Dialog    
    // build the dialog         
    var dialog = $('<div>').attr({"title":"Create MyContentType",id:"dialog"}).append(html); 

    // show the dialog        
      // reload behaviors for new form          

// Wait for DOM 
$(document).ready(function() {    
  // JavaScript hook for Ajax module  
  Drupal.Ajax.plugins.mymodule = function(hooks,args){        
      case 'complete':        
        // The AJAX form has submitted successfully so lets  update the view      
        if(args.form_id == "mycontenttype_node_form"){            
          // close dialog         

          // update my_view (This function is provided by AJAX Get API as a helper)   
      return false;       
comments powered by Disqus

© Balanced Scale Media, LLC. All right reserved.