diff options
Diffstat (limited to 'src/civetweb/test/ajax/test.html')
-rw-r--r-- | src/civetweb/test/ajax/test.html | 168 |
1 files changed, 168 insertions, 0 deletions
diff --git a/src/civetweb/test/ajax/test.html b/src/civetweb/test/ajax/test.html new file mode 100644 index 00000000..40fa0799 --- /dev/null +++ b/src/civetweb/test/ajax/test.html @@ -0,0 +1,168 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+ <head>
+ <title>Test</title>
+ <script type='text/javascript' language="javascript" src='jquery.js'></script>
+ <script type='text/javascript' language="javascript">
+ <!--
+
+ function mbox() {
+ alert('Javascript OK');
+ }
+
+
+ var totalCount = 10;
+ var pendingCount = 0;
+ var errorCount = 0;
+ var pushCount = 0;
+ var allErrorCount = 0;
+ var autoTest = false;
+ var testType = "cgi";
+
+ function NextTestType() {
+ if (testType == "cgi") testType = "lp";
+ else if (testType == "lp") testType = "lua";
+ else testType = "cgi";
+ }
+
+ function runTest(method, isAsync) {
+
+ ++pushCount;
+ document.getElementById('start').innerHTML = 'Test: ' + pushCount;
+ document.getElementById('resTotal').innerHTML = 'running';
+
+ for (var i = 1; i <= totalCount; ++i) {
+ document.getElementById('res'+i).innerHTML = "ready";
+ }
+
+ errorCount = 0;
+ pendingCount = totalCount;
+
+ for (var i = 1; i <= totalCount; ++i) {
+
+ fetch(i, method, isAsync);
+ }
+ }
+
+ function runAutoTest() {
+ if (autoTest) {
+ runTest("POST", true)
+ setTimeout("runAutoTest()", 250)
+ }
+ }
+
+
+ function fetch(id, method, isAsync) {
+
+ document.getElementById('res'+id).innerHTML = "pending";
+
+ $.ajax({
+ async: isAsync,
+ url: 'echo.' + testType + '?id=' + id,
+ type: method,
+ timeout: 2000,
+ data: { 'id' : id ,
+ 'longText1' : "adfsdfasdklkjlgasfdfjkhq345sdafbmkanq3trsdghkjqw4etrjlkabsdfkabvauiregtlkjasdbvabl4btrjawebbfjsdhbjk342r5bjksdbfkljbhasdfbhj234qjhasdg76k11234jhv900adfasddsfmzasdfhjgajsvhgkjhasdf77aefcae4fkjzasdfgukeaf7dkkegasdfigjcvxgui",
+ 'longText2' : "bsdfsdfasdklkjlgasdfjkhq345sdafbmkanq3trsdghkjqw4etrjlkabsdfkabvauiregtlkjasdbvabl4btrjawebbfjsdhbjk342r5bjksdbfkljbhasdfbhj234qjhasdg76k11234jhv900adfasddsfmzasdfhjgajsvhgkjhasdf77aefcae4fkjzasdfgukeaf7dkkegasdfigjcvxgui",
+ 'longText3' : "sdfsadagsdklkjlgasdfjkhq345sdafbmkanq3trsdghkjqw4etrjlkabsdfkabvauiregtlkjasdbvabl4btrjawebbfjsdhbjk342r5bjksdbfkljbhasdfbhj234qjhasdg76k11234jhv900adfasddsfmzasdfhjgajsvhgkjhasdf77aefcae4fkjzasdfgukeaf7dkkegasdfigjcvxgui",
+ 'longText4' : "q34sdfas3fhbkjlgasdfjkhq345sdafbmkanq3trsdghkjqw4etrjlkabsdfkabvauiregtlkjasdbvabl4btrjawebbfjsdhbjk342r5bjksdbfkljbhasdfbhj234qjhasdg76k11234jhv900adfasddsfmzasdfhjgajsvhgkjhasdf77aefcae4fkjzasdfgukeaf7dkkegasdfigjcvxgui",
+ 'longText5' : "askj2kjcvxychklgasdfjkhq345sdafbmkanq3trsdghkjqw4etrjlkabsdfkabvauiregtlkjasdbvabl4btrjawebbfjsdhbjk342r5bjksdbfkljbhasdfbhj234qjhasdg76k11234jhv900adfasddsfmzasdfhjgajsvhgkjhasdf77aefcae4fkjzasdfgukeaf7dkkegasdfigjcvxgui",
+ 'longText6' : "asdfjklhlkjhv8öajsdfjkhq345sdafbmkanq3trsdghkjqw4etrjlkabsdfkabvauiregtlkjasdbvabl4btrjawebbfjsdhbjk342r5bjksdbfkljbhasdfbhj234qjhasdg76k11234jhv900adfasddsfmzasdfhjgajsvhgkjhasdf77aefcae4fkjzasdfgukeaf7dkkegasdfigjcvxgui",
+ 'async' : isAsync
+ },
+ dataType: 'json',
+ succes: function(data) {
+ },
+ error: function() {
+ ++errorCount;
+ },
+ complete: function(jqXHR, textStatus) {
+
+ --pendingCount;
+
+ document.getElementById('res'+id).innerHTML = textStatus;
+ console.log('id: ' + id + ' (' + pendingCount + '/' + totalCount + '), status: ' + textStatus);
+
+ if (pendingCount == 0) {
+ document.getElementById('resTotal').innerHTML = 'done';
+ console.log('complete, error count: ' + errorCount);
+ allErrorCount = allErrorCount + errorCount;
+ document.getElementById('resSAll').innerHTML = 'total errors: ' + allErrorCount + "/" + (pushCount*totalCount);
+ }
+ }
+ });
+
+ }
+
+
+ //-->
+ </script>
+
+ </head>
+ <body>
+ <p>
+ <div id="start">Test not started.</div>
+ </p>
+ <p>
+ <table>
+ <tr>
+ <td>
+ <input id="testButton1" type="button" onclick="javascript:runTest('GET', false)" value="sync GET"></input>
+ </td>
+ <td>
+ <input id="testButton2" type="button" onclick="javascript:runTest('POST', false)" value="sync POST"></input>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <input id="testButton3" type="button" onclick="javascript:runTest('GET', true)" value="async GET"></input>
+ </td>
+ <td>
+ <input id="testButton4" type="button" onclick="javascript:runTest('POST', true)" value="async POST"></input>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <input id="testButton5" type="button" onclick="autoTest=!autoTest; javascript:runAutoTest()" value="automatic test"></input>
+ </td>
+ <td>
+ <input id="testButton6" type="button" onclick="NextTestType(); this.value=testType" value='cgi'></input>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <input id="testButtonReset" type="button" onclick="autoTest=false; javascript:location.reload(true)" value="reset"></input>
+ </td>
+ <td>
+ <input id="testButtonBack" type="button" onclick="history.back()" value="back"></input>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <input id="testButtonBox" type="button" onclick="javascript:mbox()" value="MsgBox"></input>
+ </td>
+ <td>
+ </td>
+ </tr>
+ </table>
+ </p>
+ <p>
+ <table border="1">
+ <tr><th>Test</th><th>Result</th></tr>
+ <tr><td>1</td><td><div id="res1">not started</div></td></tr>
+ <tr><td>2</td><td><div id="res2">not started</div></td></tr>
+ <tr><td>3</td><td><div id="res3">not started</div></td></tr>
+ <tr><td>4</td><td><div id="res4">not started</div></td></tr>
+ <tr><td>5</td><td><div id="res5">not started</div></td></tr>
+ <tr><td>6</td><td><div id="res6">not started</div></td></tr>
+ <tr><td>7</td><td><div id="res7">not started</div></td></tr>
+ <tr><td>8</td><td><div id="res8">not started</div></td></tr>
+ <tr><td>9</td><td><div id="res9">not started</div></td></tr>
+ <tr><td>10</td><td><div id="res10">not started</div></td></tr>
+ </table>
+ <div id="resTotal">Push [Test] to start.</div>
+ <div id="resSAll"></div>
+ </p>
+ </body>
+</html>
|