dtio35880438 2015-08-24 02:30
浏览 1937
已采纳

如何在jQuery中重新加载div

I have a div in which I have used submit button as follow :

<div id="collapse2" class="panel-collapse collapse">
        <div class="panel-body">
        <div class="logininput">
        <?php do_action( 'woocommerce_checkout_billing' ); ?>
        <button id="sendmail3" class="btn btn-info">Submit</button>
        </div>
        </div>
      </div>

in this when I click on button sendmail3 then a jquery is triggered as follow :

jQuery("#sendmail3").click(function(){
            var country = jQuery("#billing_country").val();
            var address = jQuery("#billing_address_1").val();
            var city = jQuery("#billing_city").val();
            var state = jQuery("#billing_state").val();
            //alert(state);
            var pincode = jQuery("#billing_postcode").val();

            var SecondData = "country="+country+"&address="+address+"&city="+city+"&state="+state+"&pincode="+pincode;
            var currenturl = jQuery(location).attr('href');
            var url = currenturl;
            jQuery.ajax({
                dataType : 'html',
                type: 'GET',
                url : url,
                data : SecondData,
                complete : function() { },
                success: function(data) 
                    {
                        jQuery("#collapse2").hide();
                        jQuery("#collapse3").show();
                    }
            });
          });

I have one more div collapse3 as follow :

<div id="collapse3" class="panel-collapse collapse">
        <div class="panel-body">
            <form name="checkout" method="post" class="checkout woocommerce-checkout" action="<?php echo esc_url( $get_checkout_url ); ?>" enctype="multipart/form-data">
            <div id="hideform">
            <?php do_action( 'woocommerce_checkout_billing' ); ?>
            </div>
            <h3 id="order_review_heading"><?php _e( 'Your order', 'woocommerce' ); ?></h3>

                <?php do_action( 'woocommerce_checkout_before_order_review' ); ?>

                <div id="order_review" class="woocommerce-checkout-review-order">
                    <?php do_action( 'woocommerce_checkout_order_review' ); ?>
                </div>

                <?php do_action( 'woocommerce_checkout_after_order_review' ); ?></div>
                </form>
                <?php do_action( 'woocommerce_after_checkout_form', $checkout ); ?>
      </div>

In this div data is loaded dynamically

What I want is that when I click on sendmail3 button then only the div collapse3 should be reloaded. How can I reload this div only without refreshing the page

  • 写回答

3条回答 默认 最新

  • douqiang7976 2015-08-24 02:33
    关注

    I think this will work.

        success: function(data) 
                    {
                        jQuery("#collapse2").hide();
                        jQuery("#collapse3").append(data); //I change this to .append() or try .html(data);
    
    
                    }
    

    Hope this works.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 请问一下这个运行结果是怎么来的
  • ¥15 这个复选框什么作用?
  • ¥15 单通道放大电路的工作原理
  • ¥30 YOLO检测微调结果p为1
  • ¥20 求快手直播间榜单匿名采集ID用户名简单能学会的
  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下