除了 Dystroy 的回答之外,这是一种通过 javascript 使用动态创建的表单发布数据的动态方式:
纯JavaScript:
var dynForm = document.createElement('form');
dynForm.setAttribute('method','POST');
dynForm.setAttribute('action','');
dynForm.setAttribute('id','dynForm');
dynForm.innerHTML = '';
dynForm.innerHTML += '<input type="hidden" name="login" value="xxxx" />';
dynForm.innerHTML += '<input type="hidden" name="password" value="xxxx" />';
dynForm.innerHTML += '<input type="hidden" name="number" value="12345" />';
dynForm.innerHTML += '<input type="hidden" name="call" value="678910" />';
document.body.appendChild(dynForm);
document.getElementById('dynForm').submit();
jQuery:
$("body").append('<form id="dynForm" action="" method="POST">');
$("#dynForm").append('<input type="hidden" name="login" value="xxxx" />');
$("#dynForm").append('<input type="hidden" name="password" value="xxxx" />');
$("#dynForm").append('<input type="hidden" name="number" value="12345" />');
$("#dynForm").append('<input type="hidden" name="call" value="678910" />');
$("body").append('</form>');
$("#dynForm").submit();
这是使用 AJAX 发布的技术:
纯JavaScript:
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST","Desired_URI",true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.setRequestHeader("Content-length", params.length);
xmlhttp.setRequestHeader("Connection", "close");
xmlhttp.send("login=xxxx&password=xxxx&number=12345&call=678910");
jQuery:
$.post({
url: 'Desired_URI',
data: {
login:'xxxx',
password:'xxxx',
number:'12345',
call:'78910'
}
});