Today to organize the previous written on the upload file, and show the progress bar of the program code, the code to optimize the collation. Solved the problem has been puzzling: Sometimes the progress bar does not reach 100%, the browser appeared suspended animation phenomenon. In IE8, the chrome test is perfect.
Project requirements:
Upload apk, show upload progress bar, upload finish start Analysis apk, and show: Analyzing APK data, please later ..., after analysis, show: Upload successfully, upload again
Because my computer installed is WinXP English version, ie default is IE7, in the test time found the progress bar does not show. Percentages are also not displayed.
Troubleshooting Issues:
1, change the DOM to jquery mode, do not show
2, to recursive calls plus delay, do not display. Plus delay code: settimeout ("getprogress (' +upid+") ", 500);
3, is the container level problem caused? The test is then performed to perform the upload period module. Add a container to the page, write a global variable I, write to the container i++ in the module called during the upload, and show that the correct call
4, that is, the progress bar and the percentage is 0, is not receiving the JSON data problem?
Because the code I returned is: Echo Json_encode ($arr); Is the JSON data itself, but to find out why, the returned data is executed once: Var dataobj=eval ("(" +data+) ");//Convert to JSON object
Displays script errors.
5, is it a cache? So will
Copy Code code as follows:
$.getjson ("processbar.php", {progress_key:upid},function (result) {
To
Copy Code code as follows:
$.getjson ("processbar.php", {progress_key:upid,time: (new Date ()). GetTime ()},function (result) {
Perfect solution to the problem.