Javascript 在php中访问jQuery创建的实时数据
我的jQuery代码中有一个方法,它生成行并将它们添加到html中的表中,如下所示(工作正常): 但它永远无法到达Javascript 在php中访问jQuery创建的实时数据,javascript,php,jquery,html,Javascript,Php,Jquery,Html,我的jQuery代码中有一个方法,它生成行并将它们添加到html中的表中,如下所示(工作正常): 但它永远无法到达foreach,因为它在那里找不到任何元素 那么,如何访问实时生成的行呢 谢谢。您发布的代码中哪一行是第21行?$username=$row->find('td',0)->明文;第22行和第23行出现相同的错误,但第20行没有错误。您不能(仅使用PHP)-重复:假设您正在使用,检查null从find()返回将有所帮助TH和TD通常是互斥的,因此可能不会出现在同一行上。事实上,您上面的
foreach
,因为它在那里找不到任何
元素
那么,如何访问实时生成的行呢
谢谢。您发布的代码中哪一行是第21行?$username=$row->find('td',0)->明文;第22行和第23行出现相同的错误,但第20行没有错误。您不能(仅使用PHP)-重复:假设您正在使用,检查
null
从find()
返回将有所帮助TH
和TD
通常是互斥的,因此可能不会出现在同一行上。事实上,您上面的示例数据在一个表中有TH
,在另一个表中有TD
。@KenY-N您是对的,我拿走了
行中的
元素,现在它只传递foreach
,我没有得到任何错误,因为它在文件中找不到任何行。
$(document).ready(function () {
$("#textDateAndTime").datetimepicker();
$(document).on("click","#ulInvite li h6",function(){
var h=this;
var selected=h.innerText.split(' ')[0];
var myExp=new RegExp(selected,"i");
$.getJSON("json_data.php",function(data){
$.each(data,function(key,val){
if((val.username.search(myExp))==0){
var output="<tr>"
+"<td>"+val.username+"</td>"
+"<td>"+val.firstName+"</td>"
+"<td>"+val.lastName+"</td>"
+"</tr>";
$("#tableInvite").append(output);
h.parentNode.parentNode.removeChild(h.parentNode);
}
});
});
});
<table name="tableInvite" id="tableInvite" border="1px solid black">
</table>
require('simplehtmldom_1_5/simple_html_dom.php');
$html = file_get_html('add_meeting.html');
foreach($html->find('tr') as $row) {
$username = $row->find('td',0)->plaintext;
$firstname = $row->find('td',1)->plaintext;
$lastname = $row->find('td',2)->plaintext;
}