【问题标题】:reloading a div on a button click using Jquery or Javascript使用 Jquery 或 Javascript 在单击按钮时重新加载 div
【发布时间】:2014-10-07 04:45:54
【问题描述】:

在弹出引导模式中单击添加按钮后

我想在数据库中添加记录并在同一页面上重新加载 div

$(document).ready(function(){
   $("#Reload").click(function(){
      $("#result").html("result reloaded successfully");
   });
});

点击“添加问题”记录插入后如何更新后台页面

我也想关闭弹出窗口

【问题讨论】:

  • 这里无法完全理解您的问题。如果你想在数据库中添加一些东西,那么你尝试的代码是什么?
  • 有什么问题?
  • 您应该使用表单操作或ajax将数据发送到php页面并在存储更新div后将其存储在数据库中。

标签: javascript php ajax


【解决方案1】:

尝试使用"$('#myModal').modal('hide');"先隐藏模型然后附加数据

//custom lib function
  $.fn.serializeObject = function()
{
    var o = {};
    var a = this.serializeArray();
    $.each(a, function() {
        if (o[this.name] !== undefined) {
            if (!o[this.name].push) {
                o[this.name] = [o[this.name]];
            }
            o[this.name].push(this.value || '');
        } else {
            o[this.name] = this.value || '';
        }
    });
    return o;
};

//uses
         $(document).ready(function(){
               $("#Reload").click(function(){
                  $('#myModal').modal('hide');
                  var jsonOfForm = $('formSelector').serializeObject()
                  $("#result").append("result reloaded successfully");
               });
            });

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多