weixin_33716557 2015-04-25 03:03 采纳率: 0%
浏览 104

为什么使用Ajax的查询速度慢?

I made a PHP class for search database with some methods. i.e LIKE, FULL TEXT and ...

I did test it on a huge database. The search speed was great, so I started to use this script in my page.

I decided to use AJAX to speed up stuff...

This is my ajax code :

    $.ajax({
        type: "POST",
        data: publisher + '&blur=true',
        url:"server/advance2.php",
        ifModified: true, /* tested with and without this */
        cache: true, /* tested with and without this */
        statusCode: { 404: function() {

                $('#target').html('<h4 class="col-md-offset-4 col-md-3 textRed textCenter farsi">Error...</h4>');

            }//404
        },//statusCode
        beforeSend: function() {

            $('#target').html('<img src="e995a9c2864f.gif" class="col-md-offset-4 col-md-3" alt="We are searching, please wait"/>');

        },
        success: function(result) {
            $('#target').html(result)
        }

    });//Ajax Request After Blur

but the search speed significantly decreased.

Would you tell me why it's happening, and how I can fix it?

  • 写回答

1条回答 默认 最新

  • weixin_33682719 2015-04-25 03:21
    关注

    A couple of quick debugging ideas:

    1) Open up the browser debugger, usually started with F12, make sure the the majority of the time of the response is waiting on the web server (vs rendering, etc.).

    2) On the server side, find the db query log and see how long the query itself is actually taking. As noted in other answers, there are a number of moving parts here. You just need to step by step and find the one that's taking longer than expected.

    评论

报告相同问题?

悬赏问题

  • ¥15 Macbookpro 连接热点正常上网,连接不了Wi-Fi。
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程
  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析