3 回答

TA貢獻1802條經(jīng)驗 獲得超6個贊
請試試這個。你需要從target.php頁面返回結果
function displayData(str){
$.ajax({
url: "target.php",
type: "POST",
data: {"value": str.value},
success: function(data){
$('#my-div').html(data);
}
});
}

TA貢獻1866條經(jīng)驗 獲得超5個贊
嘿,問題很簡單,如果您將從 ajax 獲取的數(shù)據(jù)值發(fā)布到 target.php,那么 $ ('#my-div').load('target.php')應該在 ajax 成功函數(shù)中,您必須使用這樣的 html 函數(shù)來放置數(shù)據(jù)$("#my-div").html(data)。它會直接在div中加載html格式的數(shù)據(jù)。

TA貢獻1813條經(jīng)驗 獲得超2個贊
如果您使用 .load() ,您的瀏覽器將向 target.php 發(fā)出另一個 GET 請求并顯示它,因此您的 $_POST 將為空。$('#my-div').html(data)
您可以在 success: of ajax 中使用,或者您可以在 php 中使用 $_GET 而不是 $_POST 并像這樣在 url 中傳遞變量
$('#my-div').load('target.php?value='str.value);
- 3 回答
- 0 關注
- 236 瀏覽
添加回答
舉報