User:Afuna/jquery.ajaxtip.js usage

From Dreamwidth Notes
Jump to: navigation, search

jquery.ajaxtip.js is available for general use in your own code. Here's a draft example of use:

self.element.ajaxtip({namespace:"yourownplugin"});

And then get it to load information using:

self.element.ajaxtip.("load", {  // same arguments to $.ajax, e.g.,
  url: posturl,
  data: postdata,
  success: function( data, status, jqxhr ) {
    // successfully posted, but return value indicated action wasn't successful
    if ( data.error ) { self.element.ajaxtip( "error", "error message" ) }
    else { self.element.ajaxtip("success", "success msg"); }
    self._trigger( "complete" );
  },
  error: function( jqxhr, status, error ) {
    // got back 404, 403, didn't load the page at all, etc
    self.element.ajaxtip( "error", "error message") }
    self._trigger( "complete" );
   }
})