gpt4 book ai didi

javascript - JQuery对话框内容打开后清空

转载 作者:行者123 更新时间:2023-11-28 10:54:00 24 4
gpt4 key购买 nike

我有这段代码,用于打开一个对话框,其中包含从 php 类生成的内容,唯一的问题是,在 2 秒内,代码会从对话框中清除。这是 JavaScript/JQuery:

$k('#CreateTable').click(function(e){
e.preventDefault();
var Call = $k('#CreateTable').attr('value');
var util = $k(this).attr('id');//.attr('value');
// alert(util);
$k('#dialog').dialog({
autoOpen: false,
title: 'Running Utility for: '+Call,
modal: true,
width: 450,
close: function(event, ui) {
$k("#dialog").empty(); // remove the content
}//END CLOSE
}).dialog('open');
$k.ajax({
type: "post",
url: "inc/runUtilities.php",
dataType: "html",
data: {
'utility' : util
},
success: function(data) {
//alert('success');
$k('#DlgTxt').html(data).fadeIn('slow');
}
});
//return false;
});//END DIALOG

它由以下按钮代码触发:

<div class="tab-pane fade in active" id="Utilities">
<p>
<div>
<button class="btn btn-lg btn-default" type="button"
value="Create Table" id="CreateTable" >Create Table</button>
</p>
</div>
</div>

我有什么遗漏的吗?

最佳答案

只需删除“.k”即可:$.k() 到 $()

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>

<script type="text/javascript">
$(function() {
$('#CreateTable').click(function(e){
e.preventDefault();
var Call = $('#CreateTable').attr('value');
var util = $(this).attr('id');//.attr('value');
// alert(util);
$('#dialog').dialog({
autoOpen: false,
title: 'Running Utility for: '+Call,
modal: true,
width: 450,
close: function(event, ui) {
$("#dialog").empty(); // remove the content
}//END CLOSE
}).dialog('open');
$.ajax({
type: "post",
url: "YOUR URL HERE",
dataType: "html",
data: {
'utility' : util
},
success: function(data) {
//alert('success');
$('#DlgTxt').html(data).fadeIn('slow');
}
});
//return false;
});//END DIALOG
});
</script>
</head>

<body>
<div class="tab-pane fade in active" id="Utilities">
<p>
<div>
<button class="btn btn-lg btn-default" type="button"
value="Create Table" id="CreateTable" >Create Table</button>
</p>
</div>
</div>
</body>
</html>

关于javascript - JQuery对话框内容打开后清空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27919145/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com