Home > Web Front-end > JS Tutorial > body text

nui form submission (compatible with ajax and form submit)

一个新手
Release: 2017-09-21 10:30:20
Original
2803 people have browsed it

Page:

<form id="form1" method="post">
Copy after login

Multiple form items

</form>
js:
ajax:
   var form = new nui.Form("form1");
  var data = form.getData(true, false);
  var json = nui.encode(data);   //序列化成JSON
nui.ajax({                
    url: "逻辑流或页面",                
    type: "post",                
    data: { submitData: json },                
    success: function (text) {                   
    alert("提交成功,返回结果:" + text);                
    }           
     }); 
  form表单提交:
 var form document.getElementById("form1");
form.action = "页面或页面流";
form.submit();
Copy after login

The above is the detailed content of nui form submission (compatible with ajax and form submit). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template