An issue with AJAX in IE7

Source: Internet
Author: User

Recently, a large file upload function was used for website creation. That is to say, the form element is uploaded through the INPUT file. This function supports uploading files of any size in bytes and displaying the upload progress in the browser. The server uses the HttpWorkRequest class, which is the same as uploading other large files on the Internet.

After the client calls the form submit method, it uses AJAX to obtain the progress information of the current upload from the server. This method is no problem in IE6 and FF. Because I have not installed IE7 on my home computer or my work computer, I have not tested IE7.

A few days ago, a friend sent a computer to IE7, And the progress bar information cannot be displayed after the form is submitted. At first, I thought there was a problem with the handler that the server returned the progress information. After debugging, the server found that the progress information could be obtained normally, which indicates that there was no problem with the server; later, I thought the JS script was changed. After carefully checking the code, I re-tested it in IE6 and FF. The result is that IE6 and FF are still good, and JS Code has not been moved. For this reason, I installed IE7 on the machine for single-step debugging. The final reason is that after submit, AJAX can be called to execute the send method, but before the form is completely submitted, the callback function will never be called.

Recall that when debugging the server, the obtained File Upload progress information is 99%, 100%, and so on. At that time, I thought that the file to be uploaded was not too large, and it was all about debugging on the local machine. The reason was that the file was uploaded soon. Now it seems that this is the problem. It seems that in IE7, the submit and AJAX requests use the same TCP connection, or AJAX is blocked when the submit is used (the phenomenon is the same anyway, and the progress information of the browser will not be updated without calling the callback function.

Now I think there is nothing special except that I use the form's submit method when submitting the form, rather than the form element of the submit (I will test this conjecture on Monday ). The most bizarre thing is that both IE6 and FF have passed, but IE7 alone cannot. Google does not seem to have found the same phenomenon as me. I think the character is still very good... Depressing.

Today, it was a little time to sort out the issues left behind by the past, and suddenly found that the progress bar cannot be updated under IE7, and the previous N websites were able to refresh the progress normally, the corresponding JS Code has never been changed. If it is RPWT, or does MS solve this problem in the new patch? I don't know yet. from last year to this year, IE7 has already installed N patches. I will only know when I re-installed IE7 and verify it again. However, we found another area that we didn't notice before. In the past, IE7 began to support Native HttpXmlRequest. That is to say, when creating an object instance of an asynchronous request, the code can be as direct as new as FF, however, many people mentioned on the Internet that it seems to be quite different from the previously created objects using ActiveX methods. some inexplicable problems may occur during actual use. Therefore, the cross-browser object creation method, which is popular on the Internet in the past, is new HttpXmlRequest. If it fails, you have to change the process of creating an object using ActiveX, put new HttpXmlRequest in the last case. In this example, the previous ActiveX method objects are preferentially applied. For the asynchronous request object created using the new HttpXmlRequest method in IE7, you don't have to worry about it for the time being. After all, it's just coming out and it's not mature. Even if you want to be compatible, you must first make the JS script an optimization for IE7.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.