Skip to content

Commit 467e38a

Browse files
author
Andreas Litt
committed
Improved code of debug-Tool.
1 parent 30c0e77 commit 467e38a

File tree

1 file changed

+31
-25
lines changed

1 file changed

+31
-25
lines changed

debug.html

+31-25
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
// Check for next free Number (max. 100)
1919
for(i=0;i<100;i++) {
2020
if(!($("#field_"+i).length > 0)) {
21-
// Feld erstellen
21+
// create Fields
2222
html = "<tr id=\"field_"+i+"\">";
2323
html += " <td>"+(i+1)+"</td>";
2424
html += " <td style=\"text-align:center\">";
@@ -116,34 +116,41 @@
116116

117117
// Clicked the Button
118118
$("#doIt").click(function() {
119-
$("#doIt").val("loading...");
120-
// Generate Field Data
121-
i = 0;
122-
while(($("#field_"+i).length > 0)) {
123-
key = $("#field_key_"+i).val();
124-
// nur volle Keys
125-
if(key != '') {
126-
value = $("#field_value_"+i).val();
127-
other = $("#hiddenData").val();
128-
if(other == '') {
129-
other = key + "=" + value;
130-
} else {
131-
other = other + "&" + key + "=" + value;
132-
}
133-
$("#hiddenData").val(other);
134-
}
135-
i++;
136-
}
137-
138119
$.ajax({
139120
url: $("#url").val(),
140121
type: $("#method").val(),
141122
data: $("#hiddenData").val(),
123+
beforeSend: function(request, settings) {
124+
$("#doIt").attr('disabled', 'disabled');
125+
$("#doIt").val("loading...");
126+
// Generate Field Data
127+
i = 0;
128+
other = '';
129+
while(($("#field_"+i).length > 0)) {
130+
key = $("#field_key_"+i).val();
131+
// only existing keys
132+
if(key != '') {
133+
value = $("#field_value_"+i).val();
134+
if(other == '') {
135+
other = key + "=" + value;
136+
} else {
137+
other = other + "&" + key + "=" + value;
138+
}
139+
}
140+
i++;
141+
}
142+
settings.data = other;
143+
},
144+
complete: function(request, textStatus) {
145+
$("#doIt").val('Send');
146+
$("#doIt").attr('disabled', '');
147+
},
142148
success: function(data) {
143149
$('#output').html(data);
144-
$("#doIt").val('Send');
145-
$("#hiddenData").val('');
146-
}
150+
},
151+
error: function(request, textStatus, error) {
152+
$('#output').html('<span style="color:red">'+textStatus+': '+error+'</span>');
153+
}
147154
});
148155
});
149156

@@ -238,6 +245,5 @@ <h2>REST-API Debug Tool</h2>
238245
</tr>
239246
</tbody>
240247
</table>
241-
<input id="hiddenData" type="hidden" />
242248
</body>
243-
</html>
249+
</html>

0 commit comments

Comments
 (0)