function doAjaxCall(callURL){

        var html = $.ajax({
                type            : 'POST',
                url             : callURL,
                data    : 'BIZ_ACTION_MODE=',
                async   : false,
                beforeSend: function(request) {
                                                        
showHideDiv('loadingDiv','FADE');
                                                 },
                complete: function(request){

                                                        if(request.responseText 
!= "" && request.responseText.indexOf
("404 Page not found") == -1){
                                                                alert("[Server 
Accessible]");
                                                    }else {
                                                        alert("[Server 
Inaccessible]");
                                                        var xhr = createXHR();
                                                        xhr.open('GET', 
callURL);
                                                                
xhr.onreadystatechange = function(){
                                                                      if 
(xhr.readyState == 4){
                                                                           
handleResponse(xhr.responseText)
                                                                      }
                                                                };
                                                                xhr.send();
                                                        }
                                         },
                success : function(html){
                                                        handleResponse(html);
                                        }
        }).responseText;
}

function createXHR(){

     var xhr = google.gears.factory.create('beta.httprequest');

     if(!xhr){

         try{
                xhr = new ActiveXObject('Msxml2.XMLHTTP');
         }catch (err1){
               try {
                        xhr = new ActiveXObject('Microsoft.XMLHTTP');
               }catch (err2){
                  try  {
                        xhr = new XMLHttpRequest();
                  }catch (err3){
                        xhr = false;
                  }
               }
         }
   }
   return xhr;
}

thanks for ur kind reply, I got the solution as posted above.

Thanks
Amit Kumar Verma

On Mar 30, 11:54 am, sobolanul <[email protected]> wrote:
> You have to reproduce the functionality of the server side request to
> local js and call the corresponding function.
>
> Example: let's say that you make an ajax requets to server and pass 2
> parameters and server responds with the sum of them and also with an
> "element.update" statement to modify the HTML in your page. You will
> need to create a js function with same functionality (it is entirely
> possible) and when in offline mode don't do an ajax request to server,
> but directly call the js function with same functionality (sum the
> numbers and update the HTML).
> What I did on my heavy ajax site, I made a class (Server) and I don't
> direcly make ajax calls, I call my Server.call_function(functionName)
> and call_function will make an ajax request if server is available for
> named function or will call the offline version that was previous
> mapped.
>
> On Mar 28, 12:53 pm, Amit Kumar Verma <[email protected]> wrote:
>
> > Hi All,
>
> > I am trying to make a prototype using google gear, and succeed in
> > database synchronization, capturing the files, css and scripts etx. I
> > want to use Single Page Layout where each request will be Ajax request
> > only.
>
> > My problem is gear in not intercepting my ajax call when there is no
> > server [offline mode]. Basically when there is no server, we can't
> > make an ajax request and thus gear can't intercept that request. Do
> > there is any solution to this problem, means can't we make an dummy
> > ajax request which will be intercepted by gear. If this is not
> > possible then we can't implement Single page layout using gear !!???
>
> > Thanks
> > Amit Kuma Verma.

Reply via email to