AJAX发送11 KB文本

时间:2016-07-16 09:29:33

标签: jquery ajax

我的Ajax向PHP代码发送11 KB文本。因此,发送数据需要花费太多时间,并且需要花费太多时间来执行。

这是我的代码:

 var xmlhttp;
        if (window.XMLHttpRequest){
            xmlhttp = new XMLHttpRequest();
        }else{
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange = function(){
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200){
                var replay = xmlhttp.responseText;
                alert("Response");
            }
        }
        xmlhttp.open("POST","xxx.php",true);
        var variable = 'questionsids=10405,10406,10396,10397,10398,10399,10400,10401,10402,10403,10404,10275,10276,10299,10302,10305,10307,10311,10321,10322,10319,10369,10159,10145,10081,10244,10247,10248,10320,10158,10323,10324,10325,10318,10146,10157,10147,10148,10156,10153,10155,10149,10316,10317,10251,10278,10281,10287,10290,10293,10296,10314,10315,10152,10160,10154,10150,9497,9498,4340,4344,4348,4352,4356,4360,4364,4368,4316,4320,4324,4328,4332,4336,4318,4322,4326,4330,4334,4338,4342,4346,4350,4354,4358,4362,4366,4370,4317,4319,4321,4323,4327,4329,4331,4333,4335,4337,4339,4341,4343,4345,4347,4349,4351,4355,4357,4359,4361,4363,4365,4367,4369,4371,10114,87,88,83,84,86,10242,10243,9617,9618,9619,9657,9658,9659,9660,9661,9662,9665,9666,9670,9673,9674,9675,9676,9677,9678,9679,9680,9681,9682,9683,9684,9685,9686,9746,9750,9751,9752,9753,9754,9755,9756,9757,9758,9759,9760,9763,9764,9765,9766,9767,9768,9769,9770,9771,9772,9773,9774,9775,9776,9777,9778,9779,9780,9781,9782,9783,9849,9856,9857,9858,9859,9860,9861,9863,9864,9865,9866,9867,9868,9869,9870,9871,9872,9873,9874,9875,&finalansJson=["10405:1:5.00:0.00","10406:2:5.00:0.00","10396:2:5.00:0.00","10397:2:5.00:0.00","10398:4:5.00:0.00","10399:4:5.00:0.00","10400:4:5.00:0.00","10401:4:5.00:0.00","10402:3:5.00:0.00","10403:3:5.00:0.00","10404:3:5.00:0.00","10275:3:5.00:0.00","10276:4:5.00:0.00","10299:1:5.00:0.00","10302:1:5.00:0.00","10305:1:5.00:0.00","10307:2:5.00:0.00","10311:2:5.00:0.00","10321:1:5.00:0.00","10322:1:5.00:0.00","10319:1-3%2C1-4%2C2-3%2C2-4%2C3-3%2C3-4%2C4-3%2C4-4%2C:5.00:0.00","10369::5.00:0.00","10159::5.00:0.00","10145::5.00:0.00","10081:1-3%2C2-4%2C3-3%2C4-3%2C:5.00:0.00","10244::5.00:0.00","10247::5.00:0.00","10248::5.00:0.00","10320:1-3%2C2-4%2C3-3%2C4-4%2C:5.00:0.00","10158:1-3%2C2-3%2C3-4%2C4-4%2C:5.00:0.00","10323::5.00:0.00","10324::5.00:0.00","10325:1-4%2C2-3%2C3-4%2C4-3%2C:5.00:0.00","10318:1-4%2C2-3%2C3-4%2C4-3%2C:5.00:0.00","10146:3-4%2C:5.00:0.00","10157:true:5.00:0.00","10147:true:5.00:0.00","10148:sadasdasd%2Csadasdasd%2Csadasdasd%2Csadasdasd%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2C:5.00:0.00","10156:sadasdasd%2Csadasdasd%2Csadasdasd%2Csadasdasd%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2C:5.00:0.00","10153:sadasdasd%2Csadasdasd%2Csadasdasd%2Csadasdasd%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2C:5.00:0.00","10155:1%2C2%2C:5.00:0.00","10149:1%2C2%2C:5.00:0.00","10316:1:5.00:0.00","10317:3:5.00:0.00","10251:3:5.00:0.00","10278:1:5.00:0.00","10281:1:5.00:0.00","10287:2:5.00:0.00","10290:4:5.00:0.00","10293:1:5.00:0.00","10296:1:5.00:0.00","10314:2:5.00:0.00","10315:2:5.00:0.00","10152:3:5.00:0.00","10160:1:5.00:0.00","10154:1:5.00:0.00","10150:1:5.00:0.00","9497:3:5.00:0.00","9498:4:5.00:0.00","4340:2:5.00:1.00","4344:2:5.00:1.00","4348:2:5.00:1.00","4352:2:5.00:1.00","4356:2:5.00:1.00","4360:2:5.00:1.00","4364:2:5.00:1.00","4368:2:5.00:1.00","4316:2:5.00:1.00","4320:2:5.00:1.00","4324:2:5.00:1.00","4328:2:5.00:1.00","4332:2:5.00:1.00","4336:2:5.00:1.00","4318:sadasdasd%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2C:5.00:1.00","4322:sadasdasd%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2C:5.00:1.00","4326:sadasdasd%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2C:5.00:1.00","4330:sadasdasd%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2C:5.00:1.00","4334:sadasdasd%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2C:5.00:1.00","4338:sadasdasd%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2C:5.00:1.00","4342:sadasdasd%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2C:5.00:1.00","4346:sadasdasd%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2C:5.00:1.00","4350:sadasdasd%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2C:5.00:1.00","4354:sadasdasd%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2C:5.00:1.00","4358:sadasdasd%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2C:5.00:1.00","4362:sadasdasd%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2C:5.00:1.00","4366:sadasdasd%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2C:5.00:1.00","4370:sadasdasd%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2Cundefined%2C:5.00:1.00","4317:true:5.00:1.00","4319:true:5.00:1.00","4321:true:5.00:1.00","4323:true:5.00:1.00","4327:true:5.00:1.00","4329:true:5.00:1.00","4331:true:5.00:1.00","4333:true:5.00:1.00","4335:true:5.00:1.00","4337:true:5.00:1.00","4339:true:5.00:1.00","4341:true:5.00:1.00","4343:true:5.00:1.00","4345:true:5.00:1.00","4347:true:5.00:1.00","4349:true:5.00:1.00","4351:true:5.00:1.00","4355:true:5.00:1.00","4357:true:5.00:1.00","4359:true:5.00:1.00","4361:true:5.00:1.00","4363:true:5.00:1.00","4365:true:5.00:1.00","4367:true:5.00:1.00","4369:true:5.00:1.00","4371:true:5.00:1.00","10114:3:5.00:1.00","87:3:5.00:0.00","88:3:5.00:0.00","83:2:5.00:0.00","84:3:5.00:0.00","86:3:5.00:0.00","10242:3:5.00:0.00","10243:2:5.00:0.00","9617:4:5.00:0.00","9618:4:5.00:0.00","9619:4:5.00:0.00","9657:3:5.00:0.00","9658:3:5.00:0.00","9659:3:5.00:0.00","9660:4:5.00:0.00","9661:3:5.00:0.00","9662:3:5.00:0.00","9665:4:5.00:0.00","9666:4:5.00:0.00","9670:3:5.00:0.00","9673:3:5.00:0.00","9674:3:5.00:0.00","9675:3:5.00:0.00","9676:3:5.00:0.00","9677:3:5.00:0.00","9678:3:5.00:0.00","9679:4:5.00:0.00","9680:3:5.00:0.00","9681:3:5.00:0.00","9682:3:5.00:0.00","9683:4:5.00:0.00","9684:5:5.00:0.00","9685:5:5.00:0.00","9686:3:5.00:0.00","9746:4:5.00:0.00","9750:4:5.00:0.00","9751:4:5.00:0.00","9752:5:5.00:0.00","9753:5:5.00:0.00","9754:4:5.00:0.00","9755:3:5.00:0.00","9756:4:5.00:0.00","9757:3:5.00:0.00","9758:4:5.00:0.00","9759:3:5.00:0.00","9760:4:5.00:0.00","9763:4:5.00:0.00","9764:4:5.00:0.00","9765:2:5.00:0.00","9766:2:5.00:0.00","9767:2:5.00:0.00","9768:2:5.00:0.00","9769:3:5.00:0.00","9770::5.00:0.00","9771::5.00:0.00","9772::5.00:0.00","9773::5.00:0.00","9774::5.00:0.00","9775::5.00:0.00","9776::5.00:0.00","9777::5.00:0.00","9778::5.00:0.00","9779::5.00:0.00","9780::5.00:0.00","9781::5.00:0.00","9782::5.00:0.00","9783:4:5.00:0.00","9849:2:5.00:0.00","9856:5:5.00:0.00","9857:2:5.00:0.00","9858:3:5.00:0.00","9859:3:5.00:0.00","9860:3:5.00:0.00","9861:4:5.00:0.00","9863:4:5.00:0.00","9864:3:5.00:0.00","9865:3:5.00:0.00","9866:3:5.00:0.00","9867:2:5.00:0.00","9868:2:5.00:0.00","9869:2:5.00:0.00","9870:5:5.00:0.00","9871:4:5.00:0.00","9872:5:5.00:0.00","9873:3:5.00:0.00","9874:2:5.00:0.00","9875:3:5.00:0.00"]&timer=33:12:39&eachquestiontime=[["10405","33:20:00","33:19:58"],["10396","33:19:56","33:19:54"],["10397","33:19:54","33:19:52"],["10398","33:19:52","33:19:50"],["10399","33:19:50","33:19:48"],["10400","33:19:48","33:19:46"],["10402","33:19:44","33:19:42"],["10403","33:19:42","33:19:41"],["10404","33:19:41","33:19:39"],["10275","33:19:39","33:19:38"],["10147","33:18:59","33:18:56"],["10148","33:18:56","33:18:51"],["10156","33:18:51","33:18:48"],["10153","33:18:48","33:18:43"],["10155","33:18:43","33:18:40"],["10149","33:18:40","33:18:38"],["10316","33:18:38","33:18:37"],["10317","33:18:37","33:18:34"],["10251","33:18:34","33:18:33"],["10278","33:18:33","33:18:31"],["10281","33:18:31","33:18:29"],["10287","33:18:29","33:18:27"],["10290","33:18:27","33:18:25"],["10315","33:18:23","33:18:20"],["10152","33:18:20","33:18:18"],["10160","33:18:18","33:18:16"],["10154","33:18:16","33:18:14"],["10150","33:18:14","33:18:11"],["9497","33:18:11","33:18:09"],["9498","33:18:09","33:18:07"],["4340","33:18:07","33:18:04"],["4344","33:18:04","33:18:02"],["4348","33:18:02","33:17:59"],["4352","33:17:59","33:17:57"],["4356","33:17:57","33:17:55"],["4360","33:17:55","33:17:53"],["4364","33:17:53","33:17:51"],["4368","33:17:51","33:17:49"],["4316","33:17:49","33:17:47"],["4320","33:17:47","33:17:45"],["4324","33:17:45","33:17:44"],["4328","33:17:44","33:17:42"],["10243","33:15:31","33:15:29"],["9617","33:15:29","33:15:25"],["9618","33:15:25","33:15:22"],["9619","33:15:22","33:15:19"],["9657","33:15:19","33:15:17"],["9658","33:15:17","33:15:15"],["10114","33:15:14","33:15:12"],["10114","33:15:10","33:15:08"],["87","33:15:08","33:15:06"],["88","33:15:06","33:15:02"],["83","33:15:02","33:14:59"],["84","33:14:59","33:14:56"],["86","33:14:56","33:14:54"],["10242","33:14:54","33:14:52"],["9659","33:14:49","33:14:46"],["9660","33:14:46","33:14:44"],["9661","33:14:44","33:14:42"],["9662","33:14:42","33:14:40"],["9665","33:14:40","33:14:38"],["9666","33:14:38","33:14:36"],["9670","33:14:36","33:14:34"],["9673","33:14:34","33:14:33"],["9674","33:14:33","33:14:31"],["9675","33:14:31","33:14:29"],["9676","33:14:29","33:14:27"],["9677","33:14:27","33:14:26"],["9678","33:14:26","33:14:23"],["9679","33:14:23","33:14:21"],["9680","33:14:21","33:14:20"],["9681","33:14:20","33:14:18"],["9682","33:14:18","33:14:15"],["9683","33:14:15","33:14:14"],["9684","33:14:14","33:14:11"],["9685","33:14:11","33:14:09"],["9686","33:14:09","33:14:06"],["9746","33:14:06","33:14:04"],["9750","33:14:04","33:14:01"],["9751","33:14:01","33:13:59"],["9752","33:13:59","33:13:57"],["9753","33:13:57","33:13:55"],["9754","33:13:55","33:13:54"],["9755","33:13:54","33:13:52"],["9756","33:13:52","33:13:50"],["9757","33:13:50","33:13:48"],["9758","33:13:48","33:13:45"],["9759","33:13:45","33:13:43"],["9760","33:13:43","33:13:41"],["9763","33:13:41","33:13:39"],["9764","33:13:39","33:13:38"],["9765","33:13:38","33:13:36"],["9766","33:13:36","33:13:34"],["9767","33:13:34","33:13:32"],["9768","33:13:32","33:13:31"],["9769","33:13:31","33:13:29"],["9770","33:13:29","33:13:28"],["9771","33:13:28","33:13:27"],["9772","33:13:27","33:13:27"],["9773","33:13:27","33:13:27"],["9774","33:13:27","33:13:27"],["9775","33:13:27","33:13:27"],["9776","33:13:27","33:13:27"],["9777","33:13:27","33:13:26"],["9778","33:13:26","33:13:26"],["9779","33:13:26","33:13:26"],["9780","33:13:26","33:13:26"],["9781","33:13:26","33:13:26"],["9782","33:13:26","33:13:25"],["9783","33:13:25","33:13:23"],["9849","33:13:23","33:13:22"],["9856","33:13:22","33:13:20"],["9857","33:13:20","33:13:18"],["9858","33:13:18","33:13:17"],["9859","33:13:17","33:13:15"],["9860","33:13:15","33:13:13"],["9861","33:13:13","33:13:09"],["9863","33:13:09","33:13:07"],["9864","33:13:07","33:13:05"],["9865","33:13:05","33:13:03"],["9866","33:13:03","33:12:59"],["9867","33:12:59","33:12:56"],["9868","33:12:56","33:12:54"],["9869","33:12:54","33:12:52"],["9870","33:12:52","33:12:50"],["9871","33:12:50","33:12:48"],["9872","33:12:48","33:12:47"],["9873","33:12:47","33:12:45"],["9874","33:12:45","33:12:43"],["9875","33:12:43","33:12:41"],["9874","33:12:41","33:12:39"]]&studentid=29&testid=427&duration=2000.00&totalquestions=200&totalmarks=1000.00';
        xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlhttp.setRequestHeader("Content-length", variable.length);
        xmlhttp.send(variable);

我正在使用'Godaddy'服务器。分析后,我发现它提供了缓慢的托管速度。

我不知道为什么它运作缓慢。我认为有两个原因:

  • Godaddy提供缓慢的托管速度
  • AJAX发送太长的数据

请有人帮助我!提前谢谢......

0 个答案:

没有答案