ajax response byte size

前端 未结 2 1046
花落未央
花落未央 2020-12-10 21:29

I\'m using jQuery\'s getJSONP and I want to log the duration of the call and the size of the response to be able to have some statistics about the usage of my application.

2条回答
  •  悲&欢浪女
    2020-12-10 21:49

    you can get the "Content-Length" of the response header:

    var contentsize;
    $.ajax('url', function(data, textstatus, request) {
        contentsize = request.getResponseHeader("Content-Length") / 1024;
        //do stuff with your data
    });
    

提交回复
热议问题