Php 在colorbox中更新html页面不会';不行。
所以我所拥有的很简单。我点击php主页上的一个按钮,它运行两个函数。一个函数使用php页面(仅包含html)创建一个颜色框,然后第二个函数使用javascript更改页面的元素。然而,由于某些原因,第二个函数在50%的时间内不起作用!在XAMPP(本地服务器)上测试时,它工作得很好,但在远程测试时,第二个功能有时无法运行 下面是我的代码,以便更深入地了解(如果需要的话)。这是我的主页HTML/PHP代码。onclick运行两个函数(同样,第二个有时不起作用): php是加载到colorbox中的内容,它只是一个html页面,没有我使用.php的特殊原因。这就是它看起来的样子(仅此复制/粘贴上的样式不好,无法在不丢失“代码示例”的情况下将其格式化。您需要知道的是,我提供了元素id,以便在下一个函数中编辑它们:Php 在colorbox中更新html页面不会';不行。,php,javascript,sql-server,colorbox,Php,Javascript,Sql Server,Colorbox,所以我所拥有的很简单。我点击php主页上的一个按钮,它运行两个函数。一个函数使用php页面(仅包含html)创建一个颜色框,然后第二个函数使用javascript更改页面的元素。然而,由于某些原因,第二个函数在50%的时间内不起作用!在XAMPP(本地服务器)上测试时,它工作得很好,但在远程测试时,第二个功能有时无法运行 下面是我的代码,以便更深入地了解(如果需要的话)。这是我的主页HTML/PHP代码。onclick运行两个函数(同样,第二个有时不起作用): php是加载到colorbox中的
!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>Table Info</title>
</head>
<body>
<font color="#450505" size =+5"><div id="tableinfo_number">Table # Error</div></font>
<br>
<font size ="+2"><div id="tableinfo_status">Table Status Error</div>
<div id="tableinfo_party">Party: N/A</div>
<div id="tableinfo_orders">Orders: N/A</div></font>
<br>
<br>
<hr>
<center><p><img id= "tableinfo_seatP" src="images/info_seat.png" width="92" height="42" onclick="showSeatBox(window.tableNumWin)"/><img id= "tableinfo_oneUp" src="images/info_increaseOne.png" width="45" height="50" onclick="increasetStatus(window.tableNumWin)" /><img id= "tableinfo_notif" src="images/info_notification.png" width="56" height="53" onclick="makeRequest(window.tableNumWin)"/></p></center>
</body>
</html>
同样,populateStatus只是执行一个查询,然后返回responseText。因此,我想我只是误解了这段代码是如何运行的。为什么远程执行时它不能更频繁地工作……可能是因为访问SQL server需要更多的时间?我假设一旦加载php页面,我就可以使用java编辑其中的任何元素脚本,但情况似乎并非如此。请帮助!:)以下是可能发生的情况:
<img src="<?php echo visualizeStatus($t11Status, 11) ?>" alt="" width="130" height="105" id="table11img" onclick="showBoxAndPopulate();"/>
<script type="text/javascript">
function showBoxAndPopulate()
{
$.colorbox({
href:"infoBox.php",
left: 400,
top: 100,
opacity: 0.40,
onComplete: function() { infoBoxPopulate(11); }
});
}
</script>
“alt=”“width=“130”height=“105”id=“table11img”onclick=“showBoxAndPopulate();"/>
函数showBoxAndPopulate()
{
$彩色盒({
href:“infoBox.php”,
左:400,,
前100名,
不透明度:0.40,
onComplete:function(){infoBoxPopulate(11);}
});
}
检查colorbox站点上的回调,以找到最适合您的回调
!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>Table Info</title>
</head>
<body>
<font color="#450505" size =+5"><div id="tableinfo_number">Table # Error</div></font>
<br>
<font size ="+2"><div id="tableinfo_status">Table Status Error</div>
<div id="tableinfo_party">Party: N/A</div>
<div id="tableinfo_orders">Orders: N/A</div></font>
<br>
<br>
<hr>
<center><p><img id= "tableinfo_seatP" src="images/info_seat.png" width="92" height="42" onclick="showSeatBox(window.tableNumWin)"/><img id= "tableinfo_oneUp" src="images/info_increaseOne.png" width="45" height="50" onclick="increasetStatus(window.tableNumWin)" /><img id= "tableinfo_notif" src="images/info_notification.png" width="56" height="53" onclick="makeRequest(window.tableNumWin)"/></p></center>
</body>
</html>
function infoBoxPopulate(tIDin)
{
// This needs to wait until colorbox is loaded, then do this code.
var tID = tIDin;
var tStatus;
window.tableNumWin = tID;
//var oneUpJS = document.getElementById("tableinfo_oneUp");
//oneUpJS.onclick = function() {increasetStatus(tID);}
if (window.XMLHttpRequest)
{ // code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp4=new XMLHttpRequest();
}
else
{ // code for IE6, IE5
xmlhttp4=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp4.onreadystatechange=function()
{
document.getElementById("tableinfo_number").innerHTML= "Table: " + tID;
document.getElementById("tableinfo_status").innerHTML= xmlhttp4.responseText;
populateParty(tID);
}
xmlhttp4.open("GET","populateStatus.php?tID="+tID,true);
xmlhttp4.send();
}
<img src="<?php echo visualizeStatus($t11Status, 11) ?>" alt="" width="130" height="105" id="table11img" onclick="showBoxAndPopulate();"/>
<script type="text/javascript">
function showBoxAndPopulate()
{
$.colorbox({
href:"infoBox.php",
left: 400,
top: 100,
opacity: 0.40,
onComplete: function() { infoBoxPopulate(11); }
});
}
</script>