我在进行 ajax 调用时遇到问题,然后我的弹出窗口停止工作。当我们单击弹出窗口的“确定”按钮时,我想调用 ajax。提前致谢
这是我的代码:
<div id='container'>
<div id='content'>
<div id='confirm-dialog'>
<asp:Button ID="cmdBackToHomePageTop" runat="server" Text="<< Back to Home Page" Width="160px" OnClick="cmdBackToHomePageTop_Click"/>
</div>
<!-- modal content -->
<div id='confirm'>
<div class='header'><span>Test Conformation Title</span></div>
<div class='message'></div>
<div class='buttons'>
<div class='no simplemodal-close'>Cancle</div><div id='ok' class='yes'>Ok</div>
</div>
</div>
</div>
</div>
jQuery 文件
jQuery(function ($) {
$('[id$=button],[id$=cmdBackToHomePageTop]').click(function (e) {
e.preventDefault();
// example of calling the confirm function
// you must use a callback function to perform the "yes" action
confirm("hello friends?", function () {
$.ajax({
type: "post",
url: "./default2.aspx/cmdbacktohomepagetop_click"
)};
});
});
});
function confirm(message, callback) {
$('#confirm').modal({
//closeHTML: "<a href='#' title='Close' class='modal-close'>x</a>",
position: ["20%",],
overlayId: 'confirm-overlay',
containerId: 'confirm-container',
onShow: function (dialog) {
$('.message', dialog.data[0]).append(message);
// if the user clicks "yes"
$('#ok', dialog.data[0]).click(function () {
// call the callback
if ($.isFunction(callback)) {
callback.apply();
}
// close the dialog
$.modal.close();
});
}
});
}
代码绑定:
protected void cmdBackToHomePageTop_Click(object sender, EventArgs e)
{
Response.Write("called --- cmdBackToHomePageTop_Click");
}