开发者

What is the best way to optimize a big jquery POST?

开发者 https://www.devze.com 2023-04-09 10:41 出处:网络
My problem is that after 开发者_JS百科breaking the KB size on a jquery POST, the sending time is mostly bigger than 1 sec.

My problem is that after 开发者_JS百科breaking the KB size on a jquery POST, the sending time is mostly bigger than 1 sec.

Is there a good way to optimize that?

And why it takes so long to send, so less data?


I had a similar problem, but in PHP. The thing is when you're sending POST requests with a lot of (or large) parameter values (larger than 1Kb if I remember correctly), HTTP tries to optimize the requests by sending "Expect: 100" header directive. Meaning: wait for code 100 before sending the second part (those large parameters). In my case this was exactly 2 seconds. I solved this by sending the "Expect: " header directive.

If you look in the Net tab of your FireBug, is there by and chance the an Expect parameter in the Request Header?

You can manually add the header like this (if you're using the ajax jQuery function):

$.ajax
(
    {
        url: "return.php",
        headers:
        {
            'Expect': ''
        }
    }
);

I might be completely wrong, but this sounded too familiar for me to stay silent...

0

精彩评论

暂无评论...
验证码 换一张
取 消