1 回答
TA贡献1833条经验 获得超4个赞
当查询成功时,您必须在 PHP 中添加 echo 行,然后 php 可以将消息发送回 ajax,因此更改您的 PHP 代码:
<?php
include("pConfig.php");
session_start();
$cntPending = 0;
$sql = "SELECT * FROM ci_account_info Where Status = 0";
$result = mysqli_query($db,$sql);
if (!$result)
{
printf("Error: %s\n", mysqli_error($db));
exit();
}
else
{
$cntPending = mysqli_num_rows($result);
echo $cntPending;
}
?>
而你的javascript需要稍微改变一下:
function getTimeSheetValue(user, pass) {
$.ajax({
type: 'POST',
url: '../back_php_Code/pCntPending.php',
dataType: 'text',
contentType: 'application/json; charset=utf-8',
success: function (response) {
var cell = response;
document.getElementById("lblPending").innerHTML = cell;
},
});
}
- 1 回答
- 0 关注
- 117 浏览
添加回答
举报