我写了一个ajax函数,我想在提交表单之前显示确认符号.我应该如何添加我的条件.以下是我的代码.
$.ajax({ url: "UBRDashboard.aspx/GetDllValue",dataType: "json",type: "POST",contentType: 'application/json; charset=utf-8',data: JSON.stringify({ ddlOduModel: ddlOduModel,ddlAntModel: ddlAntModel,ddlOMTModel: ddlOMTModel,ddlSapID: ddlSapID,ddlvendorName: ddlvendorName,strReqID: r.d,ddlSapDescVal: ddlSapDescVal,SITE_ADD: SITE_ADD,LATITUDE: LATITUDE,LONGITUDE: LONGITUDE,ddlEQP_SEQ: ddlEQP_SEQ,txtLinkID: txtLinkID,RJ_QUANTITY: RJ_QUANTITY,USER_NAME: USER_NAME,CREATED_DATE: CREATED_DATE,LOCATIONTYPE: LOCATIONTYPE,TOWERTYPE: TOWERTYPE }),async: true,processData: false,cache: false,success: function (r) { if (r.d == "OK") { alert('Record Saved successfully'); window.location.href = "UBRDashboard.aspx"; } },error: function (xhr) { alert('Error while selecting list..!!'); window.location.href = "ErrorPage.aspx"; } }) },error: function (xhr) { alert('Error while selecting list..!!'); window.location.href = "ErrorPage.aspx"; }
解决方法
解决方案是使用beforeSend ajax属性.
beforeSend is a pre-request callback function before it is
sent.Returning false in the beforeSend function will cancel the
request.
beforeSend:function(){ return confirm("Are you sure?"); },
AJAX
$.ajax({ url: "UBRDashboard.aspx/GetDllValue",beforeSend:function(){ return confirm("Are you sure?"); },success: function (r) { if (r.d == "OK") { alert('Record Saved successfully'); window.location.href = "UBRDashboard.aspx"; },error: function (xhr) { alert('Error while selecting list..!!'); window.location.href = "ErrorPage.aspx"; } });
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。