views:

38

answers:

0

the ajax in webview works fine if you keep using it,but if you don't do anything and wait for about 10min and try to use ajax to send data to server nothing happens.i checked the server side there is no request sent from the ajax in webview.is it bug of webview or i mess somthing up?

the ajax codes i use(the jquey $.ajax with some my own function)

function extendBaseAjax(paramObj){
if(typeof(paramObj['maxRetryTimes'])=='undefined'){
    paramObj['maxRetryTimes']=0;
}
var maxRetryTimes=paramObj['maxRetryTimes'];
var retryCounter=0;
var error=paramObj['error'];  
var errorHandler=function(XMLHttpRequest, textStatus, errorThrown){
    if(textStatus=='timeout'){
        retryCounter+=1;
        if(retryCounter<maxRetryTimes){
            $.ajax(paramObj);
        }else{
            error(textStatus);//timeout", "error", "notmodified" ,"parsererror"
        }
    }else{
        error(textStatus);
    }
}


var success=paramObj.success;

var successHandler=function(data){
    if(typeof(data)=="string"){
        data=eval('('+data+')');
    }
    success(data);
}

paramObj['success']=successHandler;
paramObj['error']=errorHandler;
paramObj['date']=new Date().getTime();//no cache
$.ajax(paramObj);

}

and most of my ajax use like thie:

        extendJsonpAjax({
        url:url,
        data:data,
        timeout:timeout,
        maxRetryTimes:maxRetryTimes,
        success:function(data){
            var resultNumber=data['resultNumber'];
            totalPageNumber=resultNumber+1
            totalPageNumber=Math.ceil(resultNumber/limit);
            executeCallBack(data,currentPageNumber,totalPageNumber);
            isAjaxCompleted=true;
        },
        error:function(textStatus){
            errorCallBack(textStatus);
            isAjaxCompleted=true;
        }
    });