Posts

Showing posts from December, 2013

Featured Post

Ajax send

.ajaxSend() Returns:  jQuery .ajaxSend(handler(event, jqXHR, ajaxOptions)) handler(event, jqXHR, ajaxOptions)   The function to be invoked. Attach a function to be executed before an Ajax request is sent. This is an  Ajax Event . Whenever an Ajax request is about to be sent, jQuery triggers the  ajaxSend  event. Any and all handlers that have been registered with the .ajaxSend()  method are executed at this time. To observe this method in action, we can set up a basic Ajax load request: <div class = "trigger" > Trigger </div> <div class = "result" ></div> <div class = "log" ></div> We can attach our event handler to any element: $ ( '.log' ). ajaxSend ( function () { $ ( this ). text ( 'Triggered ajaxSend handler.' ); }); Now, we can make an Ajax request using any jQuery method: $ ( '.trigger' ). click ( function () { $ ( '.result' ). load ( 'ajax/test.html' ); }); W...

Jquery error

Bind an event handler to the "error" JavaScript event. This method is a shortcut for  .bind('error', handler) . The  error  event is sent to elements, such as images, that are referenced by a document and loaded by the browser. It is called if the element was not loaded correctly. For example, consider a page with a simple image element: <img   alt = "Book"   id = "book"   /> The event handler can be bound to the image: $ ( '#book' )   . error ( function ()   { alert ( 'Handler for .error() called.' )   }) . attr ( "src" ,   "missing.png" ); If the image cannot be loaded (for example, because it is not present at the supplied URL), the alert is displayed: Handler for .error() called. The event handler  must  be attached before the browser fires the error event, which is why the example sets the src attribute after attaching the handler. Also, the error event may not be correctly fired when the page is serve...