數據部分中的實際交易是什麼?使用AJAX無法將值發送到PHP字符串
<form id="form" name="form">
<input type="text" name="textname" id="textname">
<input type="button" name="submit" id="submit" onclick="post();">
</form>
function post()
{
var textname = $('#textname').val();
$.ajax
({
url: 'post.php',
data: {testurl:textname},
type: "POST",
success: function (data)
{
$('#test').html(data);
console.log(data);
}
});
}
而且post.php中
<?php
echo "test";
$testurl = $_POST['textname'];
echo var_dump($testurl);
?>
回聲測試工作,但對於var_dumb輸出爲NULL(0)字符串 - 空字符串
沒有'$ _POST ['textname']'。在你的數據中,你把'textname'的值放在'testurl'中,所以你應該在尋找'$ _POST ['testurl']' –