weixin_33698043 2017-08-04 10:31 采纳率: 0%
浏览 16

symfony 3重新加载ajax表格

Hi I don't find the correct syntax to do this ..

I have two form in 2 different tab in the homepage.

form2 is a create field of one field to form 1

I submit form1 with AJAX

$('#form-indirizzo').submit(function (e) {
        e.preventDefault();
        var form =$(this);
        $.ajax({
            type:form.attr('method'),
            url:form.attr('action'),
            data:form.serialize(),
            success: function (data) {
              ->  $("#form-stufa").load(location.href+" #form-stufa>*","");
            },
            error: function(){

              }

        });
    });

it saves the data but I want also go to form1 tab ( form1 have id=form-stufa) and reload it... I try this

$("#form-stufa").load(location.href+" #form-stufa>*","");

to reload but don't work..

can help

My twig file :

-page-wall -->
                            <div id="profile-page-wall" class="stufe col s12 m12">
                                <!-- profile-page-wall-share -->
                                <div id="profile-page-wall-share" class="row">
                                    <div class="col s12">
                                        <ul class="tabs tab-profile z-depth-1 light-blue">
                                            <li class="tab col s3"><a class="white-text waves-effect waves-light active" href="#UpdateStatus"><i class="mdi-editor-border-color"></i> REGISTRA STUFA</a>
                                            </li>
                                            <li class="tab col s3"><a class="white-text waves-effect waves-light" href="#AddPhotos"><i class="mdi-image-camera-alt"></i> Lista Stufe registrate</a>
                                            </li>
                                            <li class="tab col s3"><a class="white-text waves-effect waves-light" href="#CreateAlbum"><i class="mdi-image-photo-album"></i> Aggiungi Indirizzo</a>
                                            </li>                      
                                        </ul>
                                        <!-- UpdateStatus-->
                                        <div id="UpdateStatus" class="tab-content col s12  grey lighten-4">
                                            {{form_start(form,{'attr':{'id':'form-stufa'}})}}
                                            {{form_widget(form)}}
                                              <input id="salva_stufa" class=" btn" type="submit" value="Salva" />
                                                </div>
                                            </div>
                                            {{form_end(form)}}
                                        </div>


                                    </div>


                                    <!-- AddPhotos -->
                                    <div id="AddPhotos" class="tab-content col s12  grey lighten-4">


                                    </div>
                                    <!-- CreateAlbum -->
                                    <div id="CreateAlbum" class="tab-content col s12  grey lighten-4">
                                        {{form_start(form_indirizzo,{'attr':{'id':'form-indirizzo'}})}}

                                         {{form_widget(form_indirizzo)}}
                                        <div class="row">
                                            <div class="col s12 m12 right-align">
                                                <!-- Dropdown Trigger -->
                                                <input id="salva_indirizzo" class=" btn" type="submit" value="Salva" />

                                            </div>
                                        </div>
                                        {{form_end(form_indirizzo)}}
                                    </div>
                                </div>
                            </div>

MY route :

enter image description here

  • 写回答

1条回答 默认 最新

  • MAO-EYE 2017-08-04 10:37
    关注

    Try this. $("#form-stufa") if you want to click on success tab then call click event of JQ.

      $('#form-indirizzo').submit(function (e) {
            e.preventDefault();
            var form =$(this);
            $.ajax({
                type:form.attr('method'),
                url:form.attr('action'),
                data:form.serialize(),
                success: function (data) {
                  // For redirection
                  setTimeout(function(){window.location.href="youURL#form-stuf‌​a"},500);
                  // This is for click the tab after success callback.
                  //setTimeout(function(){$("#form-stufa").click()},500);
                },
                error: function(){
    
                  }
    
            });
        });
    
    评论

报告相同问题?

悬赏问题

  • ¥18 深度学习tensorflow1,ssdv1,coco数据集训练一个模型
  • ¥100 关于注册表摄像头和麦克风的问题
  • ¥30 代码本地运行正常,但是TOMCAT部署时闪退
  • ¥15 关于#python#的问题
  • ¥15 主机可以ping通路由器但是连不上网怎么办
  • ¥15 数据库一张以时间排好序的表中,找出多次相邻的那些行
  • ¥50 关于DynamoRIO处理多线程程序时候的问题
  • ¥15 kubeadm部署k8s出错
  • ¥15 Abaqus打不开cae文件怎么办?
  • ¥15 小程序准备上线,软件开发公司需要提供哪些资料给甲方