Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to submit a form with ajax

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article focuses on "how to submit a form with ajax". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to submit a form with ajax.

Pure ajax submission

Var params = {"columnpkid": pkid}; $.ajax ({type: "post", async:true,// async, if equal to false, then synchronous url: "treepool treewise delete. Action", dataType: "json", data: params,// parameter passing success: function (msg) {/ / ajax returns success alert ("ajax returns success!") ;}, error: function (msg) {alert ("ajax returned failed!");}})

Ajax submit form

Introduce related js packages

$("# form1") .ajaxSubmit ({dataType: "json", type:'POST',resetForm:true,data: "command=submit" async:true,// async, if equal to false, then synchronous beforeSubmit:function (postdata) {return true;}, success: function (data) {/ / returns a json object var msg = data.msg; if (msg.indexOf ('success')! =-1) {alert (success) } else {alert ("failed!") ;}})

Get information about the form

$("# form"). Serialize (); at this point, I believe you have a better understanding of "how to submit a form with ajax". You might as well do it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report