gpt4 book ai didi

php - 如果 PHP 返回 0,则运行 jQuery 模式对话框

转载 作者:行者123 更新时间:2023-12-02 19:37:32 24 4
gpt4 key购买 nike

我需要运行jQuery modal dialog如果 mainOptim.php 返回 0。现在 Firebug 说 $dialog 未定义。我应该在代码中更改什么?

<script type="text/javascript">
$(document).ready(function() {
var $dialog = $('<div></div>')
.html('This dialog will show every time!')
.dialog({
autoOpen: false,
title: 'Basic Dialog'
});
});
function click_function_ps() {
$.ajax({
url: 'callpage.php?page=optim/mainOptim.php',
data: 'earl='+$('#earl').val(),
success: function(html,msg){
if(msg === '1'){
$('#opt_container').html(html);
} else {
$dialog.dialog('open');
return false;
}
}
});
}
</script>

<div id="fragment-2">
<table width="100%">
<tr>
<td width="100%">
<form name="optform" method="post" action="#">
<div class = "boxx">
<label for="earl"><span>Parameter:</span></label>
<input type="text" class="input-text" value="5" size="11" maxlength="11" name="earl" id="earl">
</div>
<br/>
<div class="buttons">
<a href="#" class="regular" onclick="click_function_ps();">
<img src="images/opt.png" alt=""/> Run
</a>
</div>
</form>
</td>
</tr>
</table>
</div>

最佳答案

这是因为您在 ready 范围内使用 var 关键字将其声明为局部变量。
删除声明前面的 var (var $dialog)。

关于php - 如果 PHP 返回 0,则运行 jQuery 模式对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10776790/

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