Posts

Showing posts from March, 2012

Javascript Prototype - Unobtrusive Timeout And Abort Methods

Reference links 1) http://www.prototypejs.org/learn/introduction-to-ajax 2) http://positionabsolute.net/blog/2008/07/prototype-ajax-request-timeout.php 3) http://www.1point21.org/web-development/javascript/javascript-prototype-unobtrusive-timeout-and-abort-methods 4) https://prototype.lighthouseapp.com/projects/8886/tickets/370-ajaxoptions-ontimeout-enhancement
This is good website about Environmental gadgets.   http://www.envirogadget.com/alternative-energy/alt%D0%B5rn%D0%B0t%D1%96v%D0%B5-en%D0%B5rgy-%D1%96n-ir%D0%B5l%D0%B0nd/

jQuery getJSON with timeout

function testAjax () {         var params = "test=123" ;         var isneedtoKillAjax = true ; // set this true         // Fire the checkajaxkill method after 10 seonds         setTimeout ( function () {             checkajaxkill ();         }, 10000 ); // 10 seconds                         // For testing purpose set the sleep for 12 seconds in php page         var myAjaxCall = jQuery . getJSON ( 'index2.php' , params , function ( data , textStatus ){                           isneedtoKillAjax = false ; // set to false             // Do your actions based on result (data OR textStatus)         });         function checkajaxkill (){             // Check isneedtoKillAjax is true or false,             // if true abort the getJsonRequest             if ( isneedtoKillAjax ){                 myAjaxCall . abort ();                 alert ( 'killing the ajax call' );                             } else {