提交POST表单后,打开一个显示结果的新窗口像表单提交一样的JavaScript发布请求会向您展示如何提交您在JavaScript中通过POST创建的表单。以下是我修改过的代码。var form = document.createElement("form");form.setAttribute("method", "post");form.setAttribute("action", "test.jsp");var hiddenField = document.createElement("input"); hiddenField.setAttribute("name", "id");hiddenField.setAttribute("value", "bob");form.appendChild(hiddenField);document.body.appendChild(form); // Not entirely sure if this is necessary form.submit();我想做的是在新窗口中打开结果。我目前正在使用类似的东西在新窗口中打开一个页面:onclick = window.open(test.html, '', 'scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,status=no');
3 回答
一只斗牛犬
TA贡献1784条经验 获得超2个赞
var urlAction = 'whatever.php';var data = {param1:'value1'};var $form = $('<form target="_blank" method="POST" action="' + urlAction + '">');$.each(data, function(k,v){ $form.append('<input type="hidden" name="' + k + '" value="' + v + '">');});$form.submit();
添加回答
举报
0/150
提交
取消