Javascript函数向struts动作类发送两次请求

时间:2014-01-08 02:07:51

标签: javascript ajax

我有一个JS函数,它向动作类发送两次请求。我不知道我应该在哪里修改它来解决问题。

以下是JS函数。问题在于ELSE部分,我正在检查runNoEmail == 1&& runEmail == 0 我提供完整的JS功能以便更好地理解

function runReportCheck(obj){
     obj = window.event.srcElement;  
     if(runEmail==1 && runNoEmail==0) 
        {
         openPopupWindow('popupType:Working');          
         runEmail=0;
             var opt = {
                     method: 'post',
                     parameters: $('formLicStrands').serialize(true),
                     onSuccess: function(t) {                 
                     destroyPopupWindow();                                                 
                             if(t.responseText=="-2"){  
                                openPopupWindow('title:Error; message: Conflict report is already being run.Please try again later.; popupType: Error; button1Value: OK;  topRightClose: false',obj);                                                   
                                 return;          
                             }else                               
                               if(t.responseText=="-3"){
                                openPopupWindow('title:Warning; message: The conflict report will run and save in the background.An email will be sent to you upon completion.; popupType: Warning; button1Value: OK;  topRightClose: false',obj);                                
                                return;
                                    }  
                               else
                               {  openPopupWindow('title:Run And Email Issue Report; URL:<c:url value="/secure/deal/conflict/newReport.dooo?"/>;formToSubmit:formLicStrands;topRightClose: false;onTitleBarCloseFunction:onConflictReportClose(<c:out value="${DEAL_BRIEF.ventanaId}"/>)',obj);  
                                }
                               return;                                            
                     },
                     onFailure: function(t) {
                         alert('Error ' + t.status + ' -- ' + t.responseText);
                     }
                 }          
                 new Ajax.Request("<%=request.getContextPath()%>/secure/deal/conflict/newReport.dooo?isRunEmailClicked=true",opt);
                 return false;
        } 
        else if(runNoEmail==1 && runEmail==0) 
        {       
         openPopupWindow('popupType:Working');          
         runNoEmail=0;
             var opt = {
                     method: 'post',
                     parameters: $('formLicStrands').serialize(true),
                     onSuccess: function(t) {                 
                     destroyPopupWindow();                                                 
                             if(t.responseText=="-11"){ 
                                openPopupWindow('title:Error; message: Conflict report is already being run.Please try again later.; popupType: Error; button1Value: OK;  topRightClose: false',obj);                                                   
                                 return;          
                             } 
                               else
                               {
                                   openPopupWindow('title:Run Issue Report; URL:<c:url value="/secure/deal/conflict/newReport.dooo?"/>;formToSubmit:formLicStrands;topRightClose: false;onTitleBarCloseFunction:onConflictReportClose(<c:out value="${DEAL_BRIEF.ventanaId}"/>)',obj);  
                                }
                               return;                                            
                     },
                     onFailure: function(t) {
                         alert('Error ' + t.status + ' -- ' + t.responseText);
                     }
                 }          
                 new Ajax.Request("<%=request.getContextPath()%>/secure/deal/conflict/newReport.dooo",opt);
                 return false;
        }else {         
            openPopupWindow('title:Run Issue Report; URL:<c:url value="/secure/deal/conflict/newReport.dooo?"/>;formToSubmit:formLicStrands;topRightClose: false;onTitleBarCloseFunction:onConflictReportClose(<c:out value="${DEAL_BRIEF.ventanaId}"/>)',obj);
            }
    return;}

0 个答案:

没有答案