-
Notifications
You must be signed in to change notification settings - Fork 0
/
post_page1.html
49 lines (39 loc) · 1.61 KB
/
post_page1.html
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
</head>
<body>
<form>
<u>4. Using Form Post</u>
<input type="button" id="btnPost" value="Send" />
<script type="text/javascript">
var $ = jQuery.noConflict();
$(function () {
$("#btnPost").bind("click", function () {
//Create a Form
/* var $form = $("<form/>").attr("id", "data_form")
.attr("action", "post_page2.php")
.attr("method", "post"); */
/* JSP way */
var $form = $("<form/>").attr("id", "data_form")
.attr("action", "post_page2.jsp")
.attr("method", "post");
$("body").append($form);
//Append the values to be send
AddParameter($form, "name", 'robby');
//Send the Form
$form[0].submit();
});
});
function AddParameter(form, name, value) {
var $input = $("<input />").attr("type", "hidden")
.attr("name", name)
.attr("value", value);
form.append($input);
}
</script>
</form>
</body>
</html>