質問編集履歴
1
情報の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -35,3 +35,85 @@
|
|
35
35
|
</form>
|
36
36
|
|
37
37
|
```
|
38
|
+
|
39
|
+
```html
|
40
|
+
|
41
|
+
<head>
|
42
|
+
|
43
|
+
<meta charset="UTF-8">
|
44
|
+
|
45
|
+
<title>test</title>
|
46
|
+
|
47
|
+
<script src="js/jquery-3.4.1.min.js"></script>
|
48
|
+
|
49
|
+
<script src="js/n_trans.js"></script>
|
50
|
+
|
51
|
+
<form name="DebugForm" action="test.php" method="post" id="AjaxForm">
|
52
|
+
|
53
|
+
<input type="submit" value="テストボタン" name="" class="btn_1 submit" >
|
54
|
+
|
55
|
+
<br>
|
56
|
+
|
57
|
+
<textarea name="source" rows="30" cols="150">
|
58
|
+
|
59
|
+
</textarea>
|
60
|
+
|
61
|
+
<script>
|
62
|
+
|
63
|
+
$('#AjaxForm').submit(function(event) {
|
64
|
+
|
65
|
+
event.preventDefault();
|
66
|
+
|
67
|
+
var $form = $(this);
|
68
|
+
|
69
|
+
var $button = $form.find('.submit');
|
70
|
+
|
71
|
+
$.ajax({
|
72
|
+
|
73
|
+
url: $form.attr('action'),
|
74
|
+
|
75
|
+
type: $form.attr('method'),
|
76
|
+
|
77
|
+
data: $form.serialize(),
|
78
|
+
|
79
|
+
timeout: 10000,
|
80
|
+
|
81
|
+
beforeSend: function(xhr, settings) {
|
82
|
+
|
83
|
+
$button.attr('disabled', true);
|
84
|
+
|
85
|
+
},
|
86
|
+
|
87
|
+
complete: function(xhr, textStatus) {
|
88
|
+
|
89
|
+
$button.attr('disabled', false);
|
90
|
+
|
91
|
+
},
|
92
|
+
|
93
|
+
success: function(result, textStatus, xhr) {
|
94
|
+
|
95
|
+
$form[0].reset();
|
96
|
+
|
97
|
+
$("#result").append(result);
|
98
|
+
|
99
|
+
},
|
100
|
+
|
101
|
+
error: function(xhr, textStatus, error) {
|
102
|
+
|
103
|
+
alert('NG...');
|
104
|
+
|
105
|
+
}
|
106
|
+
|
107
|
+
});
|
108
|
+
|
109
|
+
// …
|
110
|
+
|
111
|
+
})(jQuery);
|
112
|
+
|
113
|
+
</script>
|
114
|
+
|
115
|
+
</body>
|
116
|
+
|
117
|
+
</html>
|
118
|
+
|
119
|
+
```
|