我有问题获取php脚本的输出传递给html输入
这是我的PHP脚本
$stmt->execute();
if ($stmt->rowCount() > 0){
$row = $stmt->fetch(PDO::FETCH_ASSOC);
echo 'Found: ' . $row['doctitle'] . ' ' . $row['doctype'];
}else {
echo "error";
}
这是我的ajax
$.ajax({
type: "POST",
url: "receive.php",
data: ({dtnum: "00001"})
})
.done(function (msg) {
alert("output: " + msg);
})
.fail(function() {
alert( "Posting failed." );
});
这是我的HTML
<input type="text" name="doctitle"><br>
<input type="text" name="doctype"><br>
即时获得所需的输出但是 我想要做的是将php脚本中每一行的输出传递给每个指定的html输入
答案 0 :(得分:0)
将您的JS更改为以下内容:
$.post("receive.php", {
data: ({dtnum: "00001"})
})
.success(function (msg) {
alert("output: " + msg);
})
.error(function() {
alert( "Posting failed." );
});