我想將現場的資料從操作轉換為查看并考慮我們不能使用 Viewbag
這是我的行動
public ActionResult RenderOnetimePassword(SignInModel model)
{
var selectedCountry = _countryCallingCodeService.GetCountryCallingCodeByTwoLetterIsoCode(model.SelectedCountryTwoLetterIsoCode);
var callingCode = selectedCountry.Code;
var credential = model.CredentialType == CredentialType.Email ? model.Credential : callingCode model.Credential;
var customerfor = _customerService.GetCustomerByMobile(credential);
if (customerfor == null)
throw new ArgumentException("No customer found with the specified id");
if (selectedCountry == null)
return Json(new
{
success = false,
message = _localizationService.GetResource("Account.PhoneNumberConfirmation.NoCountryFound")
});
var verificationCodeJsonResult = GenerateVerificationCode(customerfor);
if (verificationCodeJsonResult != null)
return verificationCodeJsonResult;
var isSent = MessagingHelper.SendVerificationCodeMessageToCustomer(customerfor, credential, _code, selectedCountry,
_settingService, _tokenizer, _smsInterfaceService, _localizationService, _queuedSMSService, _logger);
var signInModel = new SignInModel()
{
Credential = credential,
CredentialType = CredentialType.PhoneNumber,
DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnLoginPage,
WaitingTimeForNextResendCodeRequestInSecond = _phoneAuthenticationSetting.WaitingTimeForNextResendCodeRequestInSeconds
};
return Json(new
{
success = true,
});
}
所以我不想要你,你看所有的行動只是誰生活在一個領域signinmodel,我需要第一次提起這個資料給予WaitingTimeForNextResendCodeRequestInSecond 的RenderOnetimePassword動作,然后我們把資料視圖和阿賈克斯程序中,我們得到了一些功能誰需要這個資料資料
@model SignInModel
$(document).on('click', function () {
$("#PassCode").click(function () {
data = { Credential: $("#Credential").val(), SelectedCountryTwoLetterIsoCode: $("#SelectedCountryTwoLetterIsoCode").val() };
var count =@Model.WaitingTimeForNextResendCodeRequestInSecond;
var counter;
function timer() {
count = count - 1;
if (count <= 0) {
clearInterval(counter);
$('.remainingTimeForResendCodeRequest').hide();
$('#PassCode').show();
return;
}
$('.remainingTimeForResendCodeRequest').text('@T("Account.SMSCodeVerification.RequestForResendCode")' " " count " " '@T("Account.SMSCodeVerification.Seconds")')
}
$(document).ready(function () {
counter = setInterval(timer, 1000);
$("#Code").trigger("focus");
});
$.ajax({
cache: false,
url: '@Url.Action("RenderOnetimePassword", "Customer")',
data: data,
type: 'post',
beforeSend: function () {
$("#Password").addClass("loading");
},
success: function (response) {
if (!response.success)
showError(response.message, response.captcha_string);
else if (response.url)
window.location.href = response.url;
else if (response.update_section)
$("." response.update_section.name).html(response.update_section.html);
},
success: function (response) {
$('#PassCode').hide();
$('.remainingTimeForResendCodeRequest').text('@T("Account.SMSCodeVerification.RequestForResendCode")' " " count " " '@T("Account.SMSCodeVerification.Seconds")')
$('.remainingTimeForResendCodeRequest').show();
if (!response.success) {
validator.showErrors({
"Code": response.message
});
}
},
uj5u.com熱心網友回復:
您可以將您的操作結果發送到您的視圖功能中
return Json(new
{
success = true,
somthing = <somthing u want send to your view >
}) ;
在您看來,在您的函式中呼叫您的結果
success: function (response) {
somevaribale = response.somthing
$('#PassCode').hide();
$('.remainingTimeForResendCodeRequest').text('@T("Account.SMSCodeVerification.RequestForResendCode")' " " count " " '@T("Account.SMSCodeVerification.Seconds")')
$('.remainingTimeForResendCodeRequest').show();
if (!response.success) {
validator.showErrors({
"Code": response.message
});
}
},
我希望它對你有用:)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/376373.html
標籤:javascript C# 查询 阿贾克斯 asp.net-mvc
上一篇:與.NET6.0中的Console.ReadLine()值混淆。在沒有任何其他輸入的情況下按[Enter]
下一篇:從xml檔案中獲取所有屬性c#
