Wednesday, June 6, 2012

very simple jquery ajax

jquery supports ranges of ajax calling, below is the very simple code

Note:

  • use method get
  • receive data as html
$(
 function(){
 // Get a reference to the content div (into which we will load content).
 var jContent = $( "#content" );
      
 // Hook up link click events to load content.
 $( "a" ).click(
 function( objEvent ){
   var jLink = $( this );
  
   // Clear status list.
   $( "#ajax-status" ).empty();
    
   // Launch AJAX request.
   $.ajax(
     {
         // The link we are accessing.
  url: jLink.attr( "href" ),
      
  // The type of request.
  type: "get",
      
  // The type of data that is getting returned.
  dataType: "html",
      
  error: function(){
   ShowStatus( "AJAX - error()" );
       
         // Load the content in to the page. 
         jContent.html( "Page Not Found!!

"                    );
  },
      
  beforeSend: function(){
   ShowStatus( "AJAX - beforeSend()" );
  },
    
  complete: function(){
   ShowStatus( "AJAX - complete()" );
  },
      
  success: function( strData ){
             ShowStatus( "AJAX - success()" );
       
   // Load the content in to the page.
   jContent.html( strData );
  }
 }       
     );
    
     // Prevent default click. 
     return( false );     
}
);
  
 }
 );

source: http://www.bennadel.com/resources/presentations/jquery/demo21/index.htm

Tuesday, June 5, 2012

jquery - get id of element that fired event

In jquery, event.target.id always refers to the element that triggers the event (or selected event). Sample below


$(document).ready(function() {
    $("a").click(function(event) {
        alert(event.target.id);
    });
});

download firefox 13 final release

In case you could not use auto upgrade, please download firefox 13 release here (link from mozilla)

http://www.mozilla.org/en-US/products/download.html?product=firefox-13.0&os=win&lang=en-US

Monday, June 4, 2012

List root folders in J2ME/Blackberry


The following code list/check all the folders that existed in SD card, which is inserted in J2ME or Blackberry running OS. Please remember to import necessarily packages (in eclipse based, us Ctrl + Shift + O)

String root = null;
Enumeration e = FileSystemRegistry.listRoots();
while (e.hasMoreElements()) {
root = (String) e.nextElement(); // device has a microSD
        if (root.equalsIgnoreCase("store")) {
          System.out.println("okies man - store/ is available");
        } else {
  System.out.println(root);
        }
}