ajax response byte size

前端 未结 2 1047
花落未央
花落未央 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:51

    $.ajax('url',function(data,textstatus,request)
    {
         var totalBytes  = request.getResponseHeader('Content-length');
    
         //if u are looking for downloaded bytes
         var dlBytes =request.responseText.length; 
    });
    

提交回复
热议问题