2 回答

TA貢獻(xiàn)1862條經(jīng)驗 獲得超6個贊
我想你想在當(dāng)前頁面('website.php')的 function.php 中注入你的函數(shù)返回的字符串(模態(tài) PHP 代碼)。為此,您必須在請求完成時注入 XMLHttpRequest 給出的響應(yīng)。
假設(shè)我們要添加其中的所有內(nèi)容
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("demo").innerHTML =
this.responseText;
}
};

TA貢獻(xiàn)1818條經(jīng)驗 獲得超3個贊
看,您沒有處理請求的響應(yīng)。所以處理響應(yīng)。并從 function.php 恢復(fù)請求的狀態(tài),如果保存了數(shù)據(jù),則打開模型。您無需轉(zhuǎn)到 function.php 頁面??创a
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
// this is response of the request //now check it
//Suppose you returned " data saved" as response from function.php
if(this.responseText='data saved'){
//Open model here
}
}
};
xhttp.open("POST", "function.php", true);
xhttp.send();
- 2 回答
- 0 關(guān)注
- 275 瀏覽
添加回答
舉報