doufang3001 2018-09-09 09:38
浏览 40

发布带有ajax标签加载的表单

I have a page with a POST form, when I submit the form the details are updated in a database. And I have another page where I use AJAX TAB, which means I load the first page with AJAX, when I do this and use the Form, the details are not updated in the database.

I would appreciate help.

  <?php
        if( isset($_POST['newcst']) )
        {
            /*client add*/
                //getting post from user add form
            $c_name = $_POST['c_name']; 
            $c_adress = $_POST['c_adress'];
            $c_idnum = $_POST['c_idnum'];
            $c_phone = $_POST['c_phone'];
            $c_mail = $_POST['c_mail'];
        echo $c_num;

        //insert client into SQL
        $wpdb->insert('se_clients',array(
            'c_name' => $c_name,
            'c_adress' => $c_adress,
            'user_id'=>$cur_id, 
            'c_num'=>$c_idnum,
            'c_phone'=>$c_phone,
            'c_mail'=>$c_mail,
        ));
      }
     ?>



      <html>
    </head>
    <body>

        <div id="newcst">
        <form action="" method="post">
            <label>Full name:</label>
            <input type='text' name='c_name' /><br><br>
            <label>ID: </label>
            <input type='text' name='c_idnum' /><br><br>
            <label>PHONE:</label>
            <input type='text' name='c_phone' /><br><br>
            <label>ADRESS: </label>
            <input type='text' name='c_adress' /><br><br>
            <label>EMAIL: </label>
            <input type='text' name='c_mail' /><br><br>
            <input name="newcst" type="submit" value="create">
          </form>
        </div>
    </body>

    </html>

Ajax tab:

$(document).ready(function() {
    $("#nav li a").click(function() {

        $("#ajax-content").empty().append("<div id='loading'><img src='http://wigot.net/project/wp-content/themes/projthem/vendor/images/loader.gif' alt='Loading' /></div>");
        $("#nav li a").removeClass('current');
        $(this).addClass('current');

        $.ajax({ url: this.href, success: function(html) {
            $("#ajax-content").empty().append(html);
            }
    });
    return false;
    });


     $("#ajax-content").empty().append("<div id='loading'><img src='http://wigot.net/project/wp-content/themes/projthem/vendor/images/loader.gif' alt='Loading' /></div>");
    $.ajax({ url: 'invoice', success: function(html) {
            $("#ajax-content").empty().append(html);
    }
    });

});
  • 写回答

2条回答 默认 最新

  • donglie9067 2018-09-09 09:41
    关注

    hover(), click(), bind(), on() and others works only after reloading page. So you can use live()

    or

    $(document).on('click', 'element', function () {
       ...
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度