您好,我想稍微修改以下脚本,以便将响应输出到 div 而不是警报,请参见粗体部分。任何帮助表示赞赏!
function processResponse() {
if (gateway.readyState == 4 && gateway.status == 200) {
alert("Done loading!\n\nThe response from the PHP script was: "+gateway.responseText);
}
}
您好,我想稍微修改以下脚本,以便将响应输出到 div 而不是警报,请参见粗体部分。任何帮助表示赞赏!
function processResponse() {
if (gateway.readyState == 4 && gateway.status == 200) {
alert("Done loading!\n\nThe response from the PHP script was: "+gateway.responseText);
}
}
如果 div 有一个 id 尝试这样的事情:
document.getElementById("divId").innerHTML = gateway.responseText;
function processResponse() {
if (gateway.readyState == 4 && gateway.status == 200) {
document.getElementById("yourDiv").innerHTML = "php script was : " + gateway.responseText;
}
}
或者如果使用 jquery
function processResponse() {
if (gateway.readyState == 4 && gateway.status == 200) {
$("#youdivid").html("php script was : " + gateway.responseText);
}
}