ajax xhr lengthComputable return false with php file

前端 未结 1 1559
盖世英雄少女心
盖世英雄少女心 2021-01-20 13:54

i\'m doing an ajax request with a XMLHttpRequest in order to show the progress of the request. It\'s working great with an html file but evt.lengthComputable return false wi

相关标签:
1条回答
  • 2021-01-20 14:24

    Because php file are dynamic, you need to set a correct Content-Length header:

    <?
    ob_start();
    /* your code here */
    
    $length = ob_get_length();
    header('Content-Length: '.$length."\r\n");
    header('Accept-Ranges: bytes'."\r\n");
    ob_end_flush(); 
    
    0 讨论(0)
提交回复
热议问题