'); //}, loginTimeout); //loginTimeout is in milliseconds $.ajax({ url: 'DataWebService.asmx/CheckLoginAndGetAccessListV2', type: "POST", data: '{"Email": ' + JSON.stringify(email) + ', "Password": ' + JSON.stringify(password) + ', "CSRFToken": ' + JSON.stringify(CSRFToken) + ', "PromoCode": ' + JSON.stringify(promoCode) + ', "Source": ' + JSON.stringify(source) +'}', contentType: "application/json; charset=utf-8", dataType: "json", xhrFields: { withCredentials: true }, loginTimeout: loginTimeout, //For json, not jsonp success: function (msg) { if (typeof timer !== 'undefined') window.clearloginTimeout(timer); //turn off the loginTimeout timer loginInProgress = false; if (localLoginRequestNum != loginRequestNum) return false; //Invalid request number, ignore ajaxStatusSuccess(section, 'Login successful, please wait...'); var blockAction = false; if (typeof postLoginJavascript == 'function') blockAction = (postLoginJavascript() == false); //false return blocks redirect/refresh if (!blockAction) { if (loginSkipRedirect) location.reload(); else theForm.submit(); //must be a form submit to allow for SSL secured form posted credentials; do not use a javascript redirect } }, //End success function error: function (xhr, textStatus, errorThrown) { if (typeof timer !== 'undefined') window.clearloginTimeout(timer); //turn off the loginTimeout timer loginInProgress = false; if (localLoginRequestNum != loginRequestNum) return false; //Invalid request number, ignore var showStandardError = true; if (typeof loginErrorJavascript == 'function') { if (loginErrorJavascript() == false) showStandardError = false; } if (showStandardError) showErrorResponse($(loginStatusSelector), xhr, textStatus, errorThrown, true); statusElement.removeClass('loading').addClass('error'); } //End error function }); return false; //block html form submit while the Ajax check is in progress, it'll submit the form when ready } // Send a Password Reset email which contains a link to reset their password function sendPasswordReset() { var statusElement = $(loginStatusSelector); var emailVal = $(loginEmailSelector).val(); var promotionCode = 'CUT:LIMITED'; //So the email is sent from the associated business unit var theForm = $(loginFormSelector); var section = theForm.parent(); if (emailVal == '') { ajaxStatusError(section, 'Email is required'); return false; } ajaxStatusLoading(section, 'Sending email, please wait...'); $.ajax({ url: 'JsonWebService.svc/SendPasswordReset', data: { Email: JSON.stringify(emailVal), PromotionCode: JSON.stringify(promotionCode) }, crossDomain: true, dataType: 'jsonp', success: function (data) { if (data.ExceptionType && data.Message) { //Error ajaxStatusError(section, data.Message); } else { ajaxStatusSuccess(section, 'Email sent, please check your inbox.'); } }, error: function () { ajaxStatusError(section, 'There was an error processing your request. Please check your email address and try again.'); } }); return false; } //Function to abort/invalidate the currently running call //Might be useful to invoke automatically if the user changes any form value; see here for change detection ideas: http://stackoverflow.com/questions/1948332/detect-all-changes-to-a-input-type-text-immediately-using-jquery function abortRequest(statusSelector, msg) { $(statusSelector).html(msg); loginInProgress = false; loginRequestNum++; return false; } } catch (err) { reportError('ajaxLogin script', err); } //]]>