在提交时在控制台中显示表单数据
问题描述:
提交表单然后将数据也发布到服务器时,是否可以在控制台中显示所有表单数据?
Is it possible to show all the form data in console when the form is submitted and then the data is posted to the server as well?
类似的东西吗?
<form action="http://whatever.com" method="POST" onSubmit="console.log(All Form Data)">
感谢
Ahmar。
Thanks Ahmar.
答
尝试
$(function() {
$('form').submit(function() {
console.log('Input 1: '+$('input[name="input1"]').val() + ' Input 2: '+ $('input[name="input2"]').val()); // etc.
});
});
或输入Id,然后
<form onSubmit="console.log('Input 1: '+document.getElementById('input1').value + ' Input 2: '+document.getElementById('input2').value)">