jian-ge

方法一:target

<html>
<body>
<form action="" method="post" target="nm_iframe">
<input type="text" id="id_input_text" name="nm_input_text" />
<input type="submit" id="id_submit" name="nm_submit" value="提交" />
</form>
<iframe id="id_iframe" name="nm_iframe" style="display:none;"></iframe>
</body>
</html>

 

方法二:使用ajax控制

<html>
<body>
<form action="" method="post" target="nm_iframe">
<input type="text" id="id_input_text" name="nm_input_text" />
<input type="submit" id="id_submit" name="nm_submit" value="提交" />
</form>
<iframe id="id_iframe" name="nm_iframe" style="display:none;"></iframe>
</body>
</html>

 

$(\'#registSubmit\').on(\'submit\', function(){
registPost()
event.preventDefault() //阻止form表单默认提交
})
function registPost () {
$.ajax({
type: "post",
url: "/api/user/register",
data: $(\'#registSubmit\').serialize(),
}).success(function(message) {
console.log(message)
}).fail(function(err){
console.log(err)
})
/*
或者用jquery.form.min.js提交
$(\'#registSubmit\').ajaxSubmit(function(message){
console.log(message);
})
*/
}

方法三:改为form表单提交改为ajax提交

 

分类:

技术点:

相关文章:

  • 2021-12-27
  • 2022-12-23
  • 2021-04-11
  • 2021-12-27
  • 2021-07-04
  • 2022-12-23
  • 2022-12-23
  • 2021-12-26
猜你喜欢
  • 2022-02-07
  • 2021-12-27
  • 2021-11-17
  • 2021-11-27
  • 2021-12-02
  • 2022-01-24
  • 2021-12-27
相关资源
相似解决方案