ajax.beginform js提交,javascript - Ajax.beginform onBegin function - Stack Overflow

I'm trying to display a dialog before sending the ajax request, but I'm not getting the correct response depending of the clicked button. but I only get two results or the dialog is displayed but the request is sent or it never sends a request.

I don't want to use pure jQuery due to my strong typed view and my controller action which expects a model, so I think this will be another very big problem I'll need to resolve.

this is my layout

Checador

@RenderSection("cs", required: false)

SOME TITLE

BLAH BLAH

@using ( Html.BeginForm("LogOff", "Login", FormMethod.Post, new { id = "logoutForm" }) )

{

@Html.AntiForgeryToken()

Cerrar Sesion

}

@RenderBody()

Abarrotes Monterrey © 2014 Mexico(Es)

@Scripts.Render("~/bundles/jquery")

@Scripts.Render("~/bundles/jqueryui")

@RenderSection("scripts", required: false)

function desaparece(data, textStatus, jqXHR) {

$("#MensajeRegistro").css({ "background-color": "rgb(252, 210, 7)", "visibility": "visible", "font-size": "1.5em", "color": "#121e2d !important" });

$(".MarcoResultados").hide("slow", function () {

});

setTimeout(function () {

$("#MensajeRegistro").css("visibility", "hidden");

}, 1550);

}

$(".number").keyup(function (event) {

var valor = $(this).val();

//var valor2 = valor.charAt(0);

$(this).val(valor);

});

$(".number").keypress(function (event) {

var valor = $(this).val();

if (event.keyCode < 48 || event.keyCode > 57) {

event.preventDefault();

}

});

below is my partial view

@model checa.Models.WrapperCla

@{

ViewBag.Title = "ChecarEntradas";

}

@section cs{

#dialog-confirm {

display:none;

}

}

@{Html.RenderPartial("~/Views/Checador/_MensajeRegistro.cshtml",Model);}

@using ( Ajax.BeginForm("Buscar", Model.singlemp, new AjaxOptions { UpdateTargetId = "BusquedaEmpleados", HttpMethod = "Post" }) )

{

@Html.Label("Nombres")

@Html.Label("Apellidos")

@Html.Label("Clave")

@Html.Label("Departamento")

}

These items will be permanently deleted and cannot be recovered. Are you sure?

@{Html.RenderPartial("~/Views/Checador/_EmpleadosEncontrados.cshtml",Model.Empleados);}

@section Scripts

{

function Confirmacion() {

var response = false;

$("#dialog-confirm").dialog({

resizable: false,

height: 140,

modal: true,

buttons: {

"Cofirmar": function () {

noenvio(response);

$(this).dialog("close");

},

"Cancelar": function () {

response = false;

$(this).dialog("close");

}

}

});

return response;

}

function noenvio(response) {

response = false;

return response;

}

}

this one is another partial view which displays the query results of the partial view

@model checa.Models.WrapperCla

@foreach ( var epm in Model.Empleadoslist )

{

using ( @Ajax.BeginForm("Checar", epm, new AjaxOptions { UpdateTargetId = "MensajeRegistro", HttpMethod = "Post", OnSuccess = "desaparece(data, status, xhr)", OnBegin = "return Confirmacion()" },

new { Class = "empleadoForm" }) )

{

@{

String convertido = "";

if ( epm.Foto != null )

{

convertido = System.Convert.ToBase64String(epm.Foto);

}

}

Empleado:@epm.nombres @epm.apellidos

Numero Empleado:@epm.idd

Departamento:@epm.Departamento

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值