Search code examples
oajax.js

OAjax: how to handle server offline and cache not available scanerio?


I am using oajax.js. Is there a way to handle the case where server is offline and data is also not available in cache?


Solution

  • Normally in given case oajax.js response with it own define error json object in which status is 404 so you can handle this in following way:

    $oajax({url: "http://localhost/phonegap/getData.php" ,  success: function(result){
                        if(result.error){
                          //data is not found in cashe
                        }
                 },
             error : function(err){
                console.log(err);
             }
        });