【问题标题】:Symfony2 jQuery div refresh withoutSymfony2 jQuery div 没有刷新
【发布时间】:2016-01-13 22:18:48
【问题描述】:

我有一个表单,我使用 jQuery 提交和工作,无需刷新页面..

$('#formnotifica').submit(   
        function(event){  
             event.preventDefault(); 
             term = $(this).serialize(); 
             url = $(this).attr('action');
             $.post( 
                     url,
                     term,
                     function(data){
                        }
                     )
        }  
   ); 

现在我只会在点击提交或几秒钟后刷新我的内容表单和日期.. 我尝试使用此代码,但给我另一个页面 Symfony 并给我问题..

$(document).ready(function() {
    $("#aggiorna").load("");
    var refreshId = setInterval(function() {
        $("#aggiorna").load("" + Math.random());
    }, 1000);
});

#aggiorna 是我的“ID”在哪里。如何刷新控制器中的查询结果?谢谢和对不起我的英语


这是代码 HTML

<div id="aggiorna">
                   <ul>
                        {% for n in notifications %}
                        {% if n.is_displayed == 0 %}
                            <li>
                      <form id="formnotifica" action="{{ path('profilo_index', {'id': n.id}) }}" method="post">
                            <input name="id" type="hidden" value="{{ n.id }}" />
                            <button class="submit" id="submit" type="submit" >{{n.text|raw}}</button>
                                </form>
                                </li>
                        {% else %}
                        <li>{{n.text|raw}}
                                </li>
                            {% endif %}
                        {% endfor %}
                        </ul>
                           </div>

在控制器中只有 DQL 查询用于更新我的数据库中的字段

【问题讨论】:

    标签: javascript php jquery ajax symfony


    【解决方案1】:

    删除:

    event.preventDefault();
    

    【讨论】:

    • 如果我删除这一行,每次点击提交时我的页面都会刷新......@scoolnico
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-19
    • 1970-01-01
    • 2012-05-20
    • 2011-03-06
    • 1970-01-01
    相关资源
    最近更新 更多