【发布时间】:2019-05-19 11:07:04
【问题描述】:
我一直在尝试在用户创建帖子后重新加载页面的一部分。
JavaScript
success: function(result)
{
$("#postsxd").load(" #postsxd");
console.log(result);
}
刀片
@foreach(Auth::user()->posts()->latest()->paginate(1) as $userpost)
<div class="ui-block" id="postsxd">
<article class="hentry post">
<div class="post__author author vcard inline-items">
<img src="{{ $userpost->user->getFirstMediaUrl('pps') ? $userpost->user->getFirstMediaUrl('pps') : '/img/ava_10.jpg' }}"
width="36" height="36" alt="author">
<div class="author-date">
<a class="h6 post__author-name fn" href="#">{{ $userpost->author }}</a>
<label style="font-size: 12px;">(Your latest post)</label>
<div class="post__date">
<time class="published" datetime="2004-07-24T18:18">9 hours ago</time>
</div>
</div>
</div>
<p>{!! $userpost->content !!}</p>
</article>
</div>
@endforeach
我不知道为什么页面没有重新加载该元素或我做错了什么。提前感谢您的帮助。
另外,如何在用户提交表单或点击后更改按钮?
【问题讨论】:
-
你试过
$("#postsxd").load( "you_file_name.html");
标签: javascript jquery ajax laravel laravel-blade