2013-03-11 4 views
0

У меня есть сайт MVC3, который создает модальное окно с вопросами безопасности. Проблема заключается в том, когда вызов Ajax возвращается, будь то успех или ошибка и модальное окно закрывается, все данные формы заканчивается на строку запроса родительского окнаmodal window places формирует данные о querystring после закрытия

$(this).dialog('destroy'); 

и

$(this).dialog('destroy').remove(); 

и

and placing close: function() { $(this).dialog('destroy'); }, 

в диалоговом конкретизации с нулевым успехом.

Как предотвратить передачу модальным окном значений формы в Querystring родительского окна?

Частичный вид, который появляется в модальном окне

<div id="resetpanel"> 
    <form name="pwreset" id="pwreset" action="" method="post"> 
     Account Number: <input type="text" name="acctNumber" id="acctNumber" /><br /> 
     <button class="btn" name="btnNext" onclick="goResetValidate();return false;">Next</button> 
    </form> 
</div> 
<div id="challengepanel"> 
    <form name="challenge" id="challenge" style="display:none;" action="" method="post"> 
     <input type="hidden" name="setNum" id="setNum" value="" /> 
     Member Number: <input type="text" name="acctNumber2" id="acctNumber2" readonly="true" /><br /> 
     <label id="Q0"></label> 
     Answer: <input type="text" name="answer1" id="answer1" /><br /> 
     <label id="Q1"></label> 
     Answer: <input type="text" name="answer2" id="answer2" /><br /> 
     <label id="Q2"></label> 
     Answer: <input type="text" name="answer3" id="answer3" /><br /> 
     <button class="btn" name="btnNext" id="challengebutton" onclick="goResetPassword();return false;">Submit</button> 
    </form> 
</div> 

AJAX звонки с Jquery

//function that captures the account number and sends them to the service for processing   
    function goResetValidate() { 

     // check that all answers are numbers only on challenge questions 
     var ruleset = { 
        required: true, 
        digits: true 
        }; 
     $('#pwreset').validate({ 
      rules: { 
       qSet0: ruleset, 
       qSet1: ruleset, 
       qSet2: ruleset 
        } 
     }); 

     // challenge questions for password reset 
     var qSet0 = ["Please enter the numeral of the month you were born (i.e. January = 1, February = 2)", "Please enter the last 4 digits of your Social Security number (i.e. 444-55-XXXX)", "Please enter your home zip code - first five digits only (i.e. 22333)."]; 
     var qSet1 = ["Please enter the day of the month you were born (i.e. 1, 2, 3, etc.).", "Please enter the 2 middle digits of your Social Security number (i.e. 444-XX-6666).", "Please enter the last 4 digits of your home telephone number (i.e. 703-555-XXXX)."]; 
     var qSet2 = ["Please enter the first 3 digits of your Social Security number (i.e. XXX-55-6666).", "Please enter the 3 middle digits of your home telephone (i.e. 703-XXX-5555).", "Please enter your home zip code - first five digits only (i.e. 22333)."]; 
     // rand for choice of questions 
     var random = (Math.ceil(Math.random() * 3) - 1); 
     var jRequest = {}; 
     var acnum = $("#acctNumber").val(); 
     jRequest.an = acnum; 

     var jData = {}; 
     jData.request = jRequest; 

     $.ajax({ 
      cache: false, 
      type: "POST", 
      async: false, 
      url: ResetValidateUrl, 
      data: JSON.stringify(jData), 
      contentType: "application/json; charset=utf-8", 
      dataType: "json", 
      success: function (splashObj) { 
       switch (splashObj.ResetValidateResult.RESPONSE) { 
        case "VALID": 
         var challengequestiondisplayed = splashObj.ResetValidateResult.RESPONSE; 
         var quest = "qSet" + random; 
         // remove reset form 
         $('#resetpanel').fadeOut("slow", function() { 
          $('#resetpanel').remove(); 
          $('#acctNumber2').val(acnum); 
          $('#setNum').val(random); 
         }); 
         $.each(eval(quest), function (index, item) { 
          $('#Q' + index).text("" + this + ""); 
         }); 
         $('form#challenge').fadeToggle("slow", "linear"); 
         break; 
        // bad member number    
        case "INVALID": 
         alert("We're sorry; the system did not recognize the Member Number entered. Please try again."); 
         break; 
        // no email on file  
        case "NO_EMAIL": 
         alert("This feature requires a valid email in the system. Please contact us to provide a valid email address."); 
         break; 
        // error  
        case "ERROR": 
         alert("We're sorry; the system was uanble to complete your request. We apologize for the inconvenience."); 
         break; 
        // system is in memo-post mode  
        case "MEMO_POST": 
         alert("The system is unavailable at this time. Please try your request again later."); 
         break; 
       } 
      }, 
      error: function (xhr) { 
       alert("A Password Web Service Error!"); 
       //$(this).dialog('destroy').remove(); 
      } 
     }); 
    } 

// функция, которая фиксирует номер счета/qeustins набор номера/ответы и отправляет их к обслуживанию для обработки
функция goResetPassword() {

 var jRequest = {}; 
     jRequest.an = $("#acctNumber2").val(); 
     jRequest.setNumber = $("#setNum").val(); 
     jRequest.answer1 = $("#answer1").val(); 
     jRequest.answer2 = $("#answer2").val(); 
     jRequest.answer3 = $("#answer3").val(); 

     var jData = {}; 
     jData.request = jRequest; 

     $.ajax({ 
      cache: false, 
      type: "POST", 
      async: false, 
      url: ResetPasswordUrl, 
      data: JSON.stringify(jData), 
      contentType: "application/json; charset=utf-8", 
      dataType: "json", 
      success: function (splashObj) { 
       switch (splashObj.ResetPasswordResult.RESPONSE) { 
        // error  
        case "ERROR": 
         alert("We're sorry; the system was uanble to complete your request. We apologize for the inconvenience."); 
         break; 
        // system is in memo-post mode  
        case "MEMO_POST": 
         alert("The system is unavailable at this time. Please try your request again later."); 
         break; 
        case "INVALID_RESPONSE": 
         alert("We're sorry; we are unable to validate your status as the NetBranch account holder based upon your answers to the security questions. Note: The information requested is based upon member data currently on file with Apple FCU. If you continue to encounter difficulties with the security questions, please contact."); 
         break; 
        case "PERM_FROZEN": 
         alert("We're sorry; For security reasons, your online account access has been disabled. We apologize for the inconvenience."); 
         break; 
        case "FROZE_NOW": 
         alert("We're sorry; we are unable to validate your status as the NetBranch account holder. For security purposes, your account has been locked. We apologize for the inconvenience. To restore access, please contact "); 
         break; 
        case "SUCCESS": 
         alert("A temporary password has been sent to the email we have on file."); 
         break; 
       } 
       return false; 
       $(this).dialog('close'); 
      }, 
      error: function (xhr) { 
       alert("Password Web Service Error!"); 
       $.dialog('close').remove; 
      } 
     }); 
    } 

Модальные окна Jquery

$(document).ready(function() { 
    $(".openDialog").live("click", function (e) { 
     e.preventDefault(); 
     $("<div></div>") 
       .addClass("dialog") 
       .attr("id", $(this).attr("data-dialog-id")) 
       .appendTo("body") 
       .dialog({ 
        title: $(this).attr("data-dialog-title"), 
        close: function() { $(this).dialog('destroy'); }, 
        modal: true, 
        width: '530px' 
       }) 
       .load(this.href); 
    }); 

    $(".close").live("click", function (e) { 
     e.preventDefault(); 
     $(this).closest(".dialog").dialog("close"); 
    }); 
}); 
+0

Попробуйте использовать атрибут типа элемента кнопки (кнопка, отправить). Из памяти элемент кнопки внутри формы может вести себя странно в некоторых браузерах, если вы не укажете тип. Если это исправится, я отвечу в качестве ответа. – Charlino

ответ

0

Слушайте, я не получаю ваш вопрос, но все-таки я попытаюсь рассмотреть вашу проблему,

$("#my-form-div").dialog({ 
    autoOpen: true, 
    width: 600, 
    height: 600, 
    modal: true, 
    draggable:true, 
    resizable:false, 
    title: 'FORM', 
    buttons: [ 
     { 
      text: "CLOSE", 
      className: 'close-button-class', 
      click: function() { 
       // do what ever you want on the close event 
       $(this).dialog("close"); 
       location.reload(); 
      } 
     } 
    ], 
    open: function() { 
    //do whatever you want on the open event. 
    $("#my-form-div").html("<%= escape_javascript(render('form_view')) %>"); 
    } 
}); 

Пожалуйста понятнее о том, что вы хотите.

+0

Прошу прощения, если я не был явным. Модальное окно открывается с частичным представлением и отображает поле ввода, в котором используется собственное число. Кнопка onclick в этом модальном окне проверяет это число в Db, используя вызов Ajax. Если они не сработают, а затем закройте окно модальности. Модальное окно отправляет номер и имя кнопки в родительский элемент в строке запроса. Я хочу, чтобы данные не попадали на адрес родителей. – Techmaniac

+0

можете ли вы разместить код? – beck03076

0

Ahhhhhh нашел его. Мне нужно было поместить метод POST в форму, чтобы предотвратить его дефолт. Я думаю, хотя я только закрывал диалоговое окно, форма представляла себя как GET по умолчанию.