-
Notifications
You must be signed in to change notification settings - Fork 20
/
jquerytest.htm
31 lines (31 loc) · 1.11 KB
/
jquerytest.htm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<!doctype html>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<body>
<form method="post" action="http://echo.opera.com/">
<input name="secret" value="=?zerokit-1ed6ba13a44a74b4cc151f69e23007d636771723f7059ae730213befeccefa20?9XuAhLWwhYpfkevRGlqLFGgwcAzO2fGSbquvf4fy??=">
<input id="useintercept" type="checkbox">
<input type="submit" name="submitter" value="valid">
<input type="button" value="submit()" onclick="this.form.submit();">
<input type="button" value="secret submit()" onclick="secretSubmit();">
</form>
<script>
document.getElementsByTagName('form')[0].addEventListener('submit', function (e) {
if (document.getElementById('useintercept').checked) {
e.preventDefault();
console.log(JSON.stringify($(e.target).serializeArray()));
}
});
function secretSubmit() {
var i = document.getElementsByName('secret')[0];
var oldForm = i.parentNode;
var f = document.createElement('form');
f.method = 'post';
f.action = 'http://echo.opera.com/';
f.appendChild(i);
f.submit();
setTimeout(function () {
console.log('this never runs');
oldForm.insertBefore(i, oldForm.firstChild);
}, 0);
}
</script>