Php 对话框未在“我的数据表”页面中打开
我使用的是datatables插件,我有一个显示对话框的按钮。这是我的代码。Php 对话框未在“我的数据表”页面中打开,php,jquery,jquery-plugins,Php,Jquery,Jquery Plugins,我使用的是datatables插件,我有一个显示对话框的按钮。这是我的代码。 <title>DataTables example</title> <style type="text/css" title="currentStyle"> @import "../../media/css/demo_page.css"; @import "../../media/css/demo_ta
<title>DataTables example</title>
<style type="text/css" title="currentStyle">
@import "../../media/css/demo_page.css";
@import "../../media/css/demo_table.css";
</style>
<script type="text/javascript" language="javascript" src="../../media/js/jquery.js"></script>
<script type="text/javascript" language="javascript" src="../../media/js/jquery.dataTables.js"></script>
<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
learn/jquery-ui-1.10.3.custom/development-bundle/ui/
<script src="127.0.0.1/learn/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.core.js"></script>
<script src="127.0.0.1/learn/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.widget.js"></script>
<script src="127.0.0.1/learn/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.mouse.js"></script>
<script src="127.0.0.1/learn/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.draggable.js"></script>
<script src="127.0.0.1/learn/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.position.js"></script>
<script src="127.0.0.1/learn/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.resizable.js"></script>
<script src="127.0.0.1/learn/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.button.js"></script>
<script src="127.0.0.1/learn/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.dialog.js"></script>
<link rel="stylesheet" href="../demos.css">
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$('#example').dataTable();
} );
function show_dialog_xyz(){
$('#dialog-modal').css('visibility','visible');
$( "#dialog-modal" ).dialog({
height: 190,
modal: true
});
}
function submitform_xyz(){
//alert('the user name is');
// DO ajax and submit value to db
var $name = $("input#id_name").val();
var $email = $("input#id_email").val();
var dataString = 'name='+ $name + '&email=' + $email;
alert(dataString);
$.ajax({
type: "POST",
url: "http://127.0.0.1/learn/DataTables-1.9.4/examples/basic_init/data_populate.php",
data: dataString,
success: function(data_in) {
if(data_in.indexOf("ERROR:")==0){
$('#message').html("<div id='message_recieved'></div>");
$('#message_recieved').html("<h2>Subscribed</h2>")
.append("<p>We will be in touch soon.</p>")
.hide()
.fadeIn(1500, function() {
$('#message').append("<img id='checkmark' src='Contact_ICON.png' />");
});
}
else{
$('#message').html("<div id='message_recieved'></div>");
$('#message_recieved').html("<h2>UnSubscribed</h2>")
.append("<p>Sorry for inconvenience.</p>")
.hide()
.fadeIn(1500, function() {
$('#message').append("<img id='checkmark' src='Contact_ICON.png' />");
});
}
}
});
}
</script>
</head>
<body id="dt_example">
<div id="container">
<div id="demo">
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example" width="100%">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<?php include "data_populate.php" ?>
</tbody>
<tfoot>
<tr>
<th> Name</th>
<th>Email</th>
</tr>
</tfoot>
</table>
</div>
<div class="spacer"></div>
</div>
<div id="message" style="display:block;">
<form id="dialog-modal" title="Basic modal dialog" style='background-color:#2980b9;visibility:hidden;display:block;float:right'>
<p>Adding the modal overlay screen makes the dialog look more prominent because it dims out the page content.</p>
Enter Name :<input type="text" value="" id="id_name"/><br>
<!--<label class="error" for="id_name" id="name_error">This field is required.</label> -->
Enter Email :<input type='text' value='' id="id_email" />
<!--<label class="error" for="id_email" id="name_error">This field is required.</label> -->
<input type='button' value='Subscribe' id='is_but_subs' onclick='submitform_xyz();'/>
</form>
</div>
<input type='button' id='but_show_dialog' onclick='show_dialog_xyz();' value='show dialog'/>
</body>
</html>
DataTables示例
@导入“../../media/css/demo_page.css”;
@导入“../../media/css/demo_table.css”;
学习/jquery-ui-1.10.3.custom/development-bundle/ui/
$(文档).ready(函数(){
$(“#示例”).dataTable();
} );
函数show_dialog_xyz(){
$('对话框模式').css('可见性','可见');
$(“#对话框模式”).dialog({
身高:190,
莫代尔:对
});
}
函数submitform_xyz(){
//警报(“用户名为”);
//执行ajax并向db提交值
var$name=$(“输入#id_name”).val();
var$email=$(“input#id_email”).val();
var dataString='name='+$name+'&email='+$email;
警报(数据串);
$.ajax({
类型:“POST”,
url:“http://127.0.0.1/learn/DataTables-1.9.4/examples/basic_init/data_populate.php",
数据:dataString,
成功:函数(数据_in){
如果(数据在索引中(“错误:”)==0){
$('#message').html(“”);
$('#message_received').html(“已订阅”)
.append(“我们将很快联系。”)
<title>DataTables example</title>
<style type="text/css" title="currentStyle">
@import "../../media/css/demo_page.css";
@import "../../media/css/demo_table.css";
</style>
<script type="text/javascript" language="javascript" src="../../media/js/jquery.js"></script>
<script type="text/javascript" language="javascript" src="../../media/js/jquery.dataTables.js"></script>
<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
learn/jquery-ui-1.10.3.custom/development-bundle/ui/
<script src="127.0.0.1/learn/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.core.js"></script>
<script src="127.0.0.1/learn/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.widget.js"></script>
<script src="127.0.0.1/learn/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.mouse.js"></script>
<script src="127.0.0.1/learn/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.draggable.js"></script>
<script src="127.0.0.1/learn/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.position.js"></script>
<script src="127.0.0.1/learn/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.resizable.js"></script>
<script src="127.0.0.1/learn/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.button.js"></script>
<script src="127.0.0.1/learn/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.dialog.js"></script>
<link rel="stylesheet" href="../demos.css">
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$('#example').dataTable();
} );
function show_dialog_xyz(){
$('#dialog-modal').css('visibility','visible');
$( "#dialog-modal" ).dialog({
height: 190,
modal: true
});
}
function submitform_xyz(){
//alert('the user name is');
// DO ajax and submit value to db
var $name = $("input#id_name").val();
var $email = $("input#id_email").val();
var dataString = 'name='+ $name + '&email=' + $email;
alert(dataString);
$.ajax({
type: "POST",
url: "http://127.0.0.1/learn/DataTables-1.9.4/examples/basic_init/data_populate.php",
data: dataString,
success: function(data_in) {
if(data_in.indexOf("ERROR:")==0){
$('#message').html("<div id='message_recieved'></div>");
$('#message_recieved').html("<h2>Subscribed</h2>")
.append("<p>We will be in touch soon.</p>")
.hide()
.fadeIn(1500, function() {
$('#message').append("<img id='checkmark' src='Contact_ICON.png' />");
});
}
else{
$('#message').html("<div id='message_recieved'></div>");
$('#message_recieved').html("<h2>UnSubscribed</h2>")
.append("<p>Sorry for inconvenience.</p>")
.hide()
.fadeIn(1500, function() {
$('#message').append("<img id='checkmark' src='Contact_ICON.png' />");
});
}
}
});
}
</script>
</head>
<body id="dt_example">
<div id="container">
<div id="demo">
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example" width="100%">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<?php include "data_populate.php" ?>
</tbody>
<tfoot>
<tr>
<th> Name</th>
<th>Email</th>
</tr>
</tfoot>
</table>
</div>
<div class="spacer"></div>
</div>
<div id="message" style="display:block;">
<form id="dialog-modal" title="Basic modal dialog" style='background-color:#2980b9;visibility:hidden;display:block;float:right'>
<p>Adding the modal overlay screen makes the dialog look more prominent because it dims out the page content.</p>
Enter Name :<input type="text" value="" id="id_name"/><br>
<!--<label class="error" for="id_name" id="name_error">This field is required.</label> -->
Enter Email :<input type='text' value='' id="id_email" />
<!--<label class="error" for="id_email" id="name_error">This field is required.</label> -->
<input type='button' value='Subscribe' id='is_but_subs' onclick='submitform_xyz();'/>
</form>
</div>
<input type='button' id='but_show_dialog' onclick='show_dialog_xyz();' value='show dialog'/>
</body>
</html>
.hide()
.fadeIn(1500,函数(){
$(“#消息”)。追加(“”);
});
}
否则{
$('#message').html(“”);
$('#消息_received').html(“取消订阅”)
.append(“很抱歉给您带来不便。”)
<title>DataTables example</title>
<style type="text/css" title="currentStyle">
@import "../../media/css/demo_page.css";
@import "../../media/css/demo_table.css";
</style>
<script type="text/javascript" language="javascript" src="../../media/js/jquery.js"></script>
<script type="text/javascript" language="javascript" src="../../media/js/jquery.dataTables.js"></script>
<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
learn/jquery-ui-1.10.3.custom/development-bundle/ui/
<script src="127.0.0.1/learn/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.core.js"></script>
<script src="127.0.0.1/learn/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.widget.js"></script>
<script src="127.0.0.1/learn/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.mouse.js"></script>
<script src="127.0.0.1/learn/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.draggable.js"></script>
<script src="127.0.0.1/learn/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.position.js"></script>
<script src="127.0.0.1/learn/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.resizable.js"></script>
<script src="127.0.0.1/learn/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.button.js"></script>
<script src="127.0.0.1/learn/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.dialog.js"></script>
<link rel="stylesheet" href="../demos.css">
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$('#example').dataTable();
} );
function show_dialog_xyz(){
$('#dialog-modal').css('visibility','visible');
$( "#dialog-modal" ).dialog({
height: 190,
modal: true
});
}
function submitform_xyz(){
//alert('the user name is');
// DO ajax and submit value to db
var $name = $("input#id_name").val();
var $email = $("input#id_email").val();
var dataString = 'name='+ $name + '&email=' + $email;
alert(dataString);
$.ajax({
type: "POST",
url: "http://127.0.0.1/learn/DataTables-1.9.4/examples/basic_init/data_populate.php",
data: dataString,
success: function(data_in) {
if(data_in.indexOf("ERROR:")==0){
$('#message').html("<div id='message_recieved'></div>");
$('#message_recieved').html("<h2>Subscribed</h2>")
.append("<p>We will be in touch soon.</p>")
.hide()
.fadeIn(1500, function() {
$('#message').append("<img id='checkmark' src='Contact_ICON.png' />");
});
}
else{
$('#message').html("<div id='message_recieved'></div>");
$('#message_recieved').html("<h2>UnSubscribed</h2>")
.append("<p>Sorry for inconvenience.</p>")
.hide()
.fadeIn(1500, function() {
$('#message').append("<img id='checkmark' src='Contact_ICON.png' />");
});
}
}
});
}
</script>
</head>
<body id="dt_example">
<div id="container">
<div id="demo">
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example" width="100%">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<?php include "data_populate.php" ?>
</tbody>
<tfoot>
<tr>
<th> Name</th>
<th>Email</th>
</tr>
</tfoot>
</table>
</div>
<div class="spacer"></div>
</div>
<div id="message" style="display:block;">
<form id="dialog-modal" title="Basic modal dialog" style='background-color:#2980b9;visibility:hidden;display:block;float:right'>
<p>Adding the modal overlay screen makes the dialog look more prominent because it dims out the page content.</p>
Enter Name :<input type="text" value="" id="id_name"/><br>
<!--<label class="error" for="id_name" id="name_error">This field is required.</label> -->
Enter Email :<input type='text' value='' id="id_email" />
<!--<label class="error" for="id_email" id="name_error">This field is required.</label> -->
<input type='button' value='Subscribe' id='is_but_subs' onclick='submitform_xyz();'/>
</form>
</div>
<input type='button' id='but_show_dialog' onclick='show_dialog_xyz();' value='show dialog'/>
</body>
</html>
.hide()
.fadeIn(1500,函数(){
$(“#消息”)。追加(“”);
});
}
}
});
}
名称
电子邮件
名称
电子邮件
添加模式覆盖屏幕使对话框看起来更加突出,因为它使页面内容变暗
<title>DataTables example</title>
<style type="text/css" title="currentStyle">
@import "../../media/css/demo_page.css";
@import "../../media/css/demo_table.css";
</style>
<script type="text/javascript" language="javascript" src="../../media/js/jquery.js"></script>
<script type="text/javascript" language="javascript" src="../../media/js/jquery.dataTables.js"></script>
<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
learn/jquery-ui-1.10.3.custom/development-bundle/ui/
<script src="127.0.0.1/learn/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.core.js"></script>
<script src="127.0.0.1/learn/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.widget.js"></script>
<script src="127.0.0.1/learn/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.mouse.js"></script>
<script src="127.0.0.1/learn/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.draggable.js"></script>
<script src="127.0.0.1/learn/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.position.js"></script>
<script src="127.0.0.1/learn/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.resizable.js"></script>
<script src="127.0.0.1/learn/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.button.js"></script>
<script src="127.0.0.1/learn/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.dialog.js"></script>
<link rel="stylesheet" href="../demos.css">
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$('#example').dataTable();
} );
function show_dialog_xyz(){
$('#dialog-modal').css('visibility','visible');
$( "#dialog-modal" ).dialog({
height: 190,
modal: true
});
}
function submitform_xyz(){
//alert('the user name is');
// DO ajax and submit value to db
var $name = $("input#id_name").val();
var $email = $("input#id_email").val();
var dataString = 'name='+ $name + '&email=' + $email;
alert(dataString);
$.ajax({
type: "POST",
url: "http://127.0.0.1/learn/DataTables-1.9.4/examples/basic_init/data_populate.php",
data: dataString,
success: function(data_in) {
if(data_in.indexOf("ERROR:")==0){
$('#message').html("<div id='message_recieved'></div>");
$('#message_recieved').html("<h2>Subscribed</h2>")
.append("<p>We will be in touch soon.</p>")
.hide()
.fadeIn(1500, function() {
$('#message').append("<img id='checkmark' src='Contact_ICON.png' />");
});
}
else{
$('#message').html("<div id='message_recieved'></div>");
$('#message_recieved').html("<h2>UnSubscribed</h2>")
.append("<p>Sorry for inconvenience.</p>")
.hide()
.fadeIn(1500, function() {
$('#message').append("<img id='checkmark' src='Contact_ICON.png' />");
});
}
}
});
}
</script>
</head>
<body id="dt_example">
<div id="container">
<div id="demo">
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example" width="100%">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<?php include "data_populate.php" ?>
</tbody>
<tfoot>
<tr>
<th> Name</th>
<th>Email</th>
</tr>
</tfoot>
</table>
</div>
<div class="spacer"></div>
</div>
<div id="message" style="display:block;">
<form id="dialog-modal" title="Basic modal dialog" style='background-color:#2980b9;visibility:hidden;display:block;float:right'>
<p>Adding the modal overlay screen makes the dialog look more prominent because it dims out the page content.</p>
Enter Name :<input type="text" value="" id="id_name"/><br>
<!--<label class="error" for="id_name" id="name_error">This field is required.</label> -->
Enter Email :<input type='text' value='' id="id_email" />
<!--<label class="error" for="id_email" id="name_error">This field is required.</label> -->
<input type='button' value='Subscribe' id='is_but_subs' onclick='submitform_xyz();'/>
</form>
</div>
<input type='button' id='but_show_dialog' onclick='show_dialog_xyz();' value='show dialog'/>
</body>
</html>
输入名称:
输入电子邮件:
但是我遇到了一个错误,即.dialog()不是函数。但是如果我在单独的页面中使用对话框,它就会工作。我应该怎么做?
任何人都可以帮助..请浏览器控制台中出现任何其他错误,而不是包含jquery ui build a的单独文件,然后下载并将其作为单个文件包含。对话框是jqueryUI的一部分,因此该页面是否同时包含jquery和jqueryUI?
<title>DataTables example</title>
<style type="text/css" title="currentStyle">
@import "../../media/css/demo_page.css";
@import "../../media/css/demo_table.css";
</style>
<script type="text/javascript" language="javascript" src="../../media/js/jquery.js"></script>
<script type="text/javascript" language="javascript" src="../../media/js/jquery.dataTables.js"></script>
<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
learn/jquery-ui-1.10.3.custom/development-bundle/ui/
<script src="127.0.0.1/learn/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.core.js"></script>
<script src="127.0.0.1/learn/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.widget.js"></script>
<script src="127.0.0.1/learn/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.mouse.js"></script>
<script src="127.0.0.1/learn/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.draggable.js"></script>
<script src="127.0.0.1/learn/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.position.js"></script>
<script src="127.0.0.1/learn/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.resizable.js"></script>
<script src="127.0.0.1/learn/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.button.js"></script>
<script src="127.0.0.1/learn/jquery-ui-1.10.3.custom/development-bundle/ui/jquery.ui.dialog.js"></script>
<link rel="stylesheet" href="../demos.css">
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$('#example').dataTable();
} );
function show_dialog_xyz(){
$('#dialog-modal').css('visibility','visible');
$( "#dialog-modal" ).dialog({
height: 190,
modal: true
});
}
function submitform_xyz(){
//alert('the user name is');
// DO ajax and submit value to db
var $name = $("input#id_name").val();
var $email = $("input#id_email").val();
var dataString = 'name='+ $name + '&email=' + $email;
alert(dataString);
$.ajax({
type: "POST",
url: "http://127.0.0.1/learn/DataTables-1.9.4/examples/basic_init/data_populate.php",
data: dataString,
success: function(data_in) {
if(data_in.indexOf("ERROR:")==0){
$('#message').html("<div id='message_recieved'></div>");
$('#message_recieved').html("<h2>Subscribed</h2>")
.append("<p>We will be in touch soon.</p>")
.hide()
.fadeIn(1500, function() {
$('#message').append("<img id='checkmark' src='Contact_ICON.png' />");
});
}
else{
$('#message').html("<div id='message_recieved'></div>");
$('#message_recieved').html("<h2>UnSubscribed</h2>")
.append("<p>Sorry for inconvenience.</p>")
.hide()
.fadeIn(1500, function() {
$('#message').append("<img id='checkmark' src='Contact_ICON.png' />");
});
}
}
});
}
</script>
</head>
<body id="dt_example">
<div id="container">
<div id="demo">
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example" width="100%">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<?php include "data_populate.php" ?>
</tbody>
<tfoot>
<tr>
<th> Name</th>
<th>Email</th>
</tr>
</tfoot>
</table>
</div>
<div class="spacer"></div>
</div>
<div id="message" style="display:block;">
<form id="dialog-modal" title="Basic modal dialog" style='background-color:#2980b9;visibility:hidden;display:block;float:right'>
<p>Adding the modal overlay screen makes the dialog look more prominent because it dims out the page content.</p>
Enter Name :<input type="text" value="" id="id_name"/><br>
<!--<label class="error" for="id_name" id="name_error">This field is required.</label> -->
Enter Email :<input type='text' value='' id="id_email" />
<!--<label class="error" for="id_email" id="name_error">This field is required.</label> -->
<input type='button' value='Subscribe' id='is_but_subs' onclick='submitform_xyz();'/>
</form>
</div>
<input type='button' id='but_show_dialog' onclick='show_dialog_xyz();' value='show dialog'/>
</body>
</html>