Home  >  Article  >  Web Front-end  >  nui form submission (compatible with ajax and form submit)

nui form submission (compatible with ajax and form submit)

一个新手
一个新手Original
2017-09-21 10:30:202808browse

Page:

<form id="form1" method="post">

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();

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!

Statement:
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