两天后的第二个问题。相同的脚本。在 while 循环中有两行构建两个表格单元格。第一个没有被评论的正在工作,结果最终出现在它应该是的地方。注释掉的那个不起作用,我不明白为什么。
我已经检查了 mysql 表中列的名称,这是正确的。表格中大约有 10 列有效。但最后9个没有。我唯一能看到的是 mysql 列的名称更长。名字会不会太长?
ajax 调用没有出错。当我使表格边框 = 1 时,我可以确定有一个单元格,但里面什么都没有。当他们都没有被评论时,第二个取消了第一个。但它自己的第一个给出一个结果。
有任何想法吗?
抱歉语法不好或者解决方案很简单。
欢迎任何建议。
获取数据.inc.php:
//Output results
if(!$facebook)
{
mysql_close();
echo json_encode('There was an error running the query: ' . mysql_error());
}
elseif(!mysql_num_rows($facebook))
{
mysql_close();
echo json_encode('No results returned');
}
else
{
$output_string = '';
$output_string .= '<table border="0">';
while($row = mysql_fetch_assoc($facebook))
{
$output_string .= '<tr>';
$output_string .= '<td>'.$row['sombem_profiler_customers_first_name'].'</td>';
//$output_string .= '<td>'.$row['sombem_profiler_customers_adress_sending_street'].'</td>';
$output_string .= '</tr>';
}
$output_string .= '</table>';
}
mysql_close();
// This echo for jquery
//$output_string = $_POST['personalNumber'];
echo json_encode($output_string);
?>
ajax.js:
function ajaxCall(){
var pnumber = document.getElementById('search-personalNumber').value;
$.ajax({
url: 'db/getdata.inc.php',
type:'POST',
dataType: 'json',
data: { personalNumber: pnumber },
success: function(output_string){
$('#result_table').append(output_string);
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
}
});
}