0

您好,我想稍微修改以下脚本,以便将响应输出到 div 而不是警报,请参见粗体部分。任何帮助表示赞赏!

function processResponse() {
    if (gateway.readyState == 4 && gateway.status == 200) {
        alert("Done loading!\n\nThe response from the PHP script was: "+gateway.responseText);
    }
}
4

2 回答 2

1

如果 div 有一个 id 尝试这样的事情:

document.getElementById("divId").innerHTML = gateway.responseText;
于 2012-10-03T13:44:36.137 回答
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);
    } 
}
于 2012-10-03T13:47:13.120 回答