In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article is about how to use Ajax to submit the form with file upload and how to hide the iframe application, the editor thinks it is very practical, so I share it for you to learn. I hope you can get something after reading this article, without saying much, follow the editor to have a look.
General forms are submitted through ajax, so it is more troublesome to encounter forms uploaded with files. The basic principle is to add a hidden iframe to the page, and then submit the form data other than the file through ajax, and in the callback function after the form data is submitted successfully, submit the file separately through form, and the target of the form of this submission file points to the hidden iframe mentioned above.
Html code
The code is as follows:
Support the upload of JPG,JPEG,GIF,BMP,SWF,RMVB,RM,AVI files
Functioncallback (msg)
{
Document.getElementByIdx_x_x ("file") .outerHTML = document.getElementByIdx_x_x ("file") .outerHTML
Document.getElementByIdx_x_x ("msg") [xss_clean] = "" + msg+ ""
}
The main thing to do in index.html is to write a form and iframe, and set the target of form to the name of iframe, pay attention to setting iframe to be invisible, the rest are normal file upload writing, so that the refreshed page is the hidden Iframe, and there will be no page refresh in index.html, the callback method of js is the callback method. Used to empty the file upload box and display background information, pay attention to the method of emptying the file upload box, which is a little different from the common method.
Upload.jsp9Dhjsp code
The code is as follows:
In upload.jsp, just pay attention to the format of the final output. In fact, the principle is to output a piece of js code to iframe, and then control its parent page in iframe.
OK, at this point, a non-refresh page upload component is done, do not forget to add the necessary jspSmartUpload.jar package under WEB-INF/lib.
It should be noted that when uploading using Iframe, the status bar will still be refreshed, because the page in iframe has been refreshed, but the external page, that is, the page you see has not been refreshed, so it can also be said to be similar to Ajax upload.
The above is how to use Ajax to submit forms with file uploads and how to hide iframe applications. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.