I was just learning and used ajaxSubmit. I hesitated because I had never been exposed to this before, so I was confused at first. Finally, I solved this problem by searching for information. I was very excited and uploaded the page without refreshing. Picture, I would like to give a sentence to friends who read my blog: "The mountain is high, and hard work will determine success!"
Let me summarize ajaxSubmit below:
1.Introduce jQuery;
2.Download the jQuery Form plug-in online;
Here is an introduction to the form plug-in, because people who are just starting to do front-end work may not understand it. , jQuery Form plug-in is an excellent Ajax form plug-in, which can easily and non-invasively upgrade HTML forms to support Ajax.
jQuery Form has two core methods - ajaxForm() and ajaxSubmit(), which combine functions from controlling form elements to deciding how to manage the submission process.
In addition, the plug-in also includes other methods:
formToArray(), formSerialize(), fieldSerialize(), fieldValue(), clearForm(), clearFields() and resetForm ()wait.
Core methods: ajaxForm() and ajaxSubmit()
3. Let’s talk about usage first. Both ajaxForm and ajaxSubmit can receive 0 or 1 parameter, which can be a variable, An object or callback function. This object mainly has the following parameters:
var object= { url:url, //form提交数据的地址 type:type, //form提交的方式(method:post/get) target:target, //服务器返回的响应数据显示的元素(Id)号 beforeSerialize:function(){} //序列化提交数据之前的回调函数 beforeSubmit:function(){}, //提交前执行的回调函数 success:function(){}, //提交成功后执行的回调函数 error:function(){}, //提交失败执行的函数 dataType:null, //服务器返回数据类型 clearForm:true, //提交成功后是否清空表单中的字段值 restForm:true, //提交成功后是否重置表单中的字段值,即恢复到页面加载时的状态 timeout:6000 //设置请求时间,超过该时间后,自动退出请求,单位(毫秒)。 }
Recommended Manual:
1.AJAX Chinese Reference Manual
2.jQuery Chinese Reference Manual
nbsp;html> <title>权限信息展示 </title> <link> <link> <script></script> <script></script>//这里引入 <script></script> <script></script> <script></script> <script></script> <script> $(function () { //绑定异步上传图片 bindUpLoad(); }); //绑定异步上传图片 function bindUpLoad() { alert("aaaaa"); $("#btnUpLoadFile").click(function () { alert("bbbbb"); $("#AddDiglogp form").ajaxSubmit({ url: '/ActionInfo/UploadImg', type: "Post", success: function (data) { alert("ccccc"); //将返回的数据加载到隐藏域 $("#IconImg").val(data); $("#ShowImgp").html("<img src="/static/imghwm/default1.png" data-src="https://img.php.cn/upload/article/000/054/025/acb67e7ebe827c4111f01d6f21485af9-0.png?x-oss-process=image/resize,p_40" class="lazy" src='" + data + "' style='width:100px; height:80px'/ alt="Detailed explanation of ajaxSubmit in jQuery" >"); } }); }); }</script>
The HTML code is like this:
<!-------------添加对话框 start---------------------> <p> @using (Ajax.BeginForm("AddActionInfo", "ActionInfo", new AjaxOptions() { OnSuccess = "afterAdd" })) { </p>
权 限 名: | |
Url: | |
Http方法类型: | |
是否是菜单: | |
菜单图片地址: | |
排 序: | |
备 注: |
The final project to be completed is like this:
Finally, I successfully implemented the function of uploading images asynchronously without refreshing!
Recommended related articles:
1.Solving the problem of AjaxSubmit uploading files under IE prompts for downloading files
2.How to use AjaxSubmit() Submit file
3.How to solve JQuery ajaxSubmit to submit Chinese garbled characters
Related video recommendations:
1.Dugu Jiujian(6 )_jQuery video tutorial
2.AJAX basic video tutorial
The above is the detailed content of Detailed explanation of ajaxSubmit in jQuery. For more information, please follow other related articles on the PHP Chinese website!

The main difference between Python and JavaScript is the type system and application scenarios. 1. Python uses dynamic types, suitable for scientific computing and data analysis. 2. JavaScript adopts weak types and is widely used in front-end and full-stack development. The two have their own advantages in asynchronous programming and performance optimization, and should be decided according to project requirements when choosing.

Whether to choose Python or JavaScript depends on the project type: 1) Choose Python for data science and automation tasks; 2) Choose JavaScript for front-end and full-stack development. Python is favored for its powerful library in data processing and automation, while JavaScript is indispensable for its advantages in web interaction and full-stack development.

Python and JavaScript each have their own advantages, and the choice depends on project needs and personal preferences. 1. Python is easy to learn, with concise syntax, suitable for data science and back-end development, but has a slow execution speed. 2. JavaScript is everywhere in front-end development and has strong asynchronous programming capabilities. Node.js makes it suitable for full-stack development, but the syntax may be complex and error-prone.

JavaScriptisnotbuiltonCorC ;it'saninterpretedlanguagethatrunsonenginesoftenwritteninC .1)JavaScriptwasdesignedasalightweight,interpretedlanguageforwebbrowsers.2)EnginesevolvedfromsimpleinterpreterstoJITcompilers,typicallyinC ,improvingperformance.

JavaScript can be used for front-end and back-end development. The front-end enhances the user experience through DOM operations, and the back-end handles server tasks through Node.js. 1. Front-end example: Change the content of the web page text. 2. Backend example: Create a Node.js server.

Choosing Python or JavaScript should be based on career development, learning curve and ecosystem: 1) Career development: Python is suitable for data science and back-end development, while JavaScript is suitable for front-end and full-stack development. 2) Learning curve: Python syntax is concise and suitable for beginners; JavaScript syntax is flexible. 3) Ecosystem: Python has rich scientific computing libraries, and JavaScript has a powerful front-end framework.

The power of the JavaScript framework lies in simplifying development, improving user experience and application performance. When choosing a framework, consider: 1. Project size and complexity, 2. Team experience, 3. Ecosystem and community support.

Introduction I know you may find it strange, what exactly does JavaScript, C and browser have to do? They seem to be unrelated, but in fact, they play a very important role in modern web development. Today we will discuss the close connection between these three. Through this article, you will learn how JavaScript runs in the browser, the role of C in the browser engine, and how they work together to drive rendering and interaction of web pages. We all know the relationship between JavaScript and browser. JavaScript is the core language of front-end development. It runs directly in the browser, making web pages vivid and interesting. Have you ever wondered why JavaScr


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Atom editor mac version download
The most popular open source editor

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.
