jQuery Ajax调用,错误函数是调用但成功不调用

时间:2016-11-29 06:19:56

标签: javascript jquery ajax

function processAjaxCalls(url,data,onsuccessCallBack,onerrorCallBack,dataType,requestId,hideProcessing){    
    if(requestId != null &&requestId != undefined &&requestId.length > 0 && requestId != "")
    {

        if( ajaxRequests[ requestId ] )
            ajaxRequests[ requestId ].abort();
    }   
    alert("1");
    if(hideProcessing!=true)
        show_winMask(1);
    var reqObj = jQuery.ajax({
           type: "POST",
           url: url,
           dataType: (dataType != null && dataType != undefined && dataType.length > 0)? dataType :  "json",
           data:data,
           success: function(result)
           {
               alert("process SUCCESS RESULT"+result);
               if( ajaxRequests[ requestId ] )
                  delete ajaxRequests[ requestId ];
              if(hideProcessing!=true)  
                  show_winMask(0);
              if( result != null && result.sExpires){
                   loadFormSessionTimeOut(result);
              }
              //eval( '('+onsuccessCallBack +'(result) )' );
              alert("bfefore var args");
              var args = [result];
              dynamicFunctionCall(onsuccessCallBack, args);

           },

           error:function(status)
           {

               alert("process STATUS ERROR"+status);
               if( status.statusText != "abort"){
                   if( ajaxRequests[ requestId ] )
                      delete ajaxRequests[ requestId ];
                   if(hideProcessing!=true)
                       show_winMask(0);
                   eval( '('+onerrorCallBack +'(status) )' );
              }

               if( status != null && status.sExpires){
                   loadFormSessionTimeOut(status);
               } 
           }

    }); 


    if( requestId != null && requestId != undefined && requestId.length > 0 && requestId != "")
        ajaxRequests[ requestId ] = reqObj;

}

错误功能正在运行,但成功无效..我如何纠正?

1 个答案:

答案 0 :(得分:0)

“成功不起作用”问题出现两个通常的原因。首先检查您正在调用的服务器脚本是否返回正确的值。第二个是您从客户端发送的URL和数据。这就是在ajax中成功调用所需的全部内容