简体   繁体   English

从jQuery刷新PHP Blade的foreach循环

[英]Refresh php blade foreach loop from jQuery

So in my html I have foreach cycle, and at some moment some data gets posted from javascript, and I'd like to append it when in is added to the database. 因此,在我的html中,我有一个foreach循环,有时会从javascript中发布一些数据,并且当in被添加到数据库时,我想附加它。

So I need to refresh foreach somehow without refreshing the whole page (I could just append() data from javascript, but there is too mush to make string out of them). 因此,我需要以某种方式刷新foreach 而不刷新整个页面 (我可以只从javascript追加append()数据,但是要从它们中提取字符串实在太糊涂了)。

Any suggestions? 有什么建议么? Any possible help would be highly appreciated. 任何可能的帮助将不胜感激。

The loop itself is placed in table rows: 循环本身位于表行中:

<tbody>
    @foreach($tags as $tag)
        <tr data-row-id="{{$tag->id}}">
            <td class="text-left " style="">{{$tag->id }}</td>
            <td class="text-left " style="">{{$tag->title}}</td>
            <td class="text-right" style=""><a href="#" name="{{$tag->id}}" data-name="{{$tag->title }}" class="btn-floating btn-medium waves-effect waves-light red delete-tag"><i class="material-icons left white-text" name="{{$tag->id}}">delete</i></a></td>
        </tr>
    @endforeach
</tbody>

and my javascript posts the data of new tag, and gets its full information back from controller 和我的javascript发布新标签的数据,并从控制器获取其完整信息

Well I just moved the whole table into the separate particular view, and it gets loaded again after posting is completed. 好吧,我只是将整个表移到单独的特定视图中,并且在完成发布后再次将其加载。 Probably not the best option, but still working one 可能不是最好的选择,但仍然可以工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM