如何从JavaScript的POST请求中获取响应

3

我在这里使用找到的这个post请求,但我想知道如何使用它来接收响应...

function post_to_url(path, params, method) {
    method = method || "post"; 
    var form = document.createElement("form");
    form.setAttribute("method", method);
    form.setAttribute("action", path);

    for(var key in params) {
        if(params.hasOwnProperty(key)) {
            var hiddenField = document.createElement("input");
            hiddenField.setAttribute("type", "hidden");
            hiddenField.setAttribute("name", key);
            hiddenField.setAttribute("value", params[key]);

            form.appendChild(hiddenField);
         }
    }ody.appendChild(form);
    form.submit();
}

预先感谢你。

看一下 AJAX。它比提交表单更适合你的目的。 - Sirko
1个回答

1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接