您好我想稍微修改下面的脚本,以便它将响应输出到div而不是警报,请参阅粗体部分。任何帮助表示赞赏!
function processResponse() {
if (gateway.readyState == 4 && gateway.status == 200) {
alert("Done loading!\n\nThe response from the PHP script was: "+gateway.responseText);
}
}
答案 0 :(得分:1)
如果div有id,请尝试这样的事情:
document.getElementById("divId").innerHTML = gateway.responseText;
答案 1 :(得分:0)
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);
}
}