Note that there are some explanatory texts on larger screens.

plurals
  1. POmodal window places form data on querystring after close
    primarykey
    data
    text
    <p>I have a MVC3 site that produces a modal window with security questions. The problem is, when the ajax call comes back, whether success or error and the modal window is closed, all the form data ends up on the querystring of the parent window </p> <pre><code>$(this).dialog('destroy'); </code></pre> <p><strong>and</strong></p> <pre><code> $(this).dialog('destroy').remove(); </code></pre> <p><strong>and</strong></p> <pre><code>and placing close: function () { $(this).dialog('destroy'); }, </code></pre> <p>in the dialog instantiation with zero success.</p> <p>How do I prevent the modal window from passing the form values to the Parent windows querystring?</p> <p><strong>Partial View that appears in modal window</strong></p> <pre><code> &lt;div id="resetpanel"&gt; &lt;form name="pwreset" id="pwreset" action="" method="post"&gt; Account Number: &lt;input type="text" name="acctNumber" id="acctNumber" /&gt;&lt;br /&gt; &lt;button class="btn" name="btnNext" onclick="goResetValidate();return false;"&gt;Next&lt;/button&gt; &lt;/form&gt; &lt;/div&gt; &lt;div id="challengepanel"&gt; &lt;form name="challenge" id="challenge" style="display:none;" action="" method="post"&gt; &lt;input type="hidden" name="setNum" id="setNum" value="" /&gt; Member Number: &lt;input type="text" name="acctNumber2" id="acctNumber2" readonly="true" /&gt;&lt;br /&gt; &lt;label id="Q0"&gt;&lt;/label&gt; Answer: &lt;input type="text" name="answer1" id="answer1" /&gt;&lt;br /&gt; &lt;label id="Q1"&gt;&lt;/label&gt; Answer: &lt;input type="text" name="answer2" id="answer2" /&gt;&lt;br /&gt; &lt;label id="Q2"&gt;&lt;/label&gt; Answer: &lt;input type="text" name="answer3" id="answer3" /&gt;&lt;br /&gt; &lt;button class="btn" name="btnNext" id="challengebutton" onclick="goResetPassword();return false;"&gt;Submit&lt;/button&gt; &lt;/form&gt; &lt;/div&gt; </code></pre> <p><strong>AJAX calls with Jquery</strong></p> <pre><code>//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(); } }); } </code></pre> <p>//function that captures the account number/qeustins set number/answers and sends them to the service for processing<br> function goResetPassword() {</p> <pre><code> 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; } }); } </code></pre> <p><strong>Modal Window Jquery</strong></p> <pre><code>$(document).ready(function () { $(".openDialog").live("click", function (e) { e.preventDefault(); $("&lt;div&gt;&lt;/div&gt;") .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"); }); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload