zoukankan      html  css  js  c++  java
  • 好用的一段Ajax无刷新提交表单代码

     1 <script type="text/javascript">
    2 $(function () {
    3
    4 // Initialize progress dialog ...
    5 $("#ProgressDialog").dialog({
    6 autoOpen: false,
    7 draggable: false,
    8 modal: true,
    9 resizable: false,
    10 title: "Loading",
    11 closeOnEscape: false,
    12 open: function () { $(".ui-dialog-titlebar-close").hide(); } // Hide close button
    13 });
    14
    15 // Handle form submit ...
    16 $("form").live("submit", function (event) {
    17 event.preventDefault();
    18 var form = $(this);
    19 $("#ProgressDialog").dialog("open");
    20 $.ajax({
    21 url: form.attr('action'),
    22 type: "POST",
    23 data: form.serialize(),
    24 success: function (data) {
    25 $("#FormContainer").html(data);
    26 $.validator.unobtrusive.parse("form");
    27 },
    28 error: function (jqXhr, textStatus, errorThrown) {
    29 alert("Error '" + jqXhr.status + "' (textStatus: '" + textStatus + "', errorThrown: '" + errorThrown + "')");
    30 },
    31 complete: function () {
    32 $("#ProgressDialog").dialog("close");
    33 }
    34 });
    35 });
    36 });
    37 </script>
  • 相关阅读:
    CentOS 6.x 系统安装选项说明
    MySQL表的操作
    6月13号
    6月11号
    6月10号
    6月9号
    6月6
    day27
    day 28
    day 29
  • 原文地址:https://www.cnblogs.com/huangmeimujin/p/2305781.html
Copyright © 2011-2022 走看看