获取已发布的帖子字段并使用jquery更新它们

时间:2016-07-19 14:24:26

标签: javascript jquery ajax laravel modal-dialog

我正在使用laravel,想要编辑包含多个字段的帖子进行编辑。 我已经用我的帖子的身体领域成功完成了这项工作,希望与其他两个人合作。

相关

df_Office_final_sparktable[2:2, 1:3]
代码:

df_Office_final_sparktable[2:2, 1:3]
需要获取早期数据的

controller

最后是我的$post->body=$data['body']; $post->state = $data['state']; $post->problem_domain = $data['problem_domain']; $post->update(); return response()->json(['new_body'=>$post->body],500); ,请查看blade的格式是否正确,并希望对其他两种格式执行此操作

<article class="post" data-postid="{{ $post->id }}">
    <p> {{ $post->body }} </p>
    <p> <b> Region: </b> {{ $post->state }} &nbsp <b> Problem Domain: </b>
    {{ $post->problem_domain}}</p>
    <div class="info">
       posted by <b>{{ $post->user->name }}</b>  on 
       <b>{{ $post->created_at }}</b>
    </div>
    <div class="interaction">
      <a href="#" class="like">{{ Auth::user()->likes()->where('post_id',$post->id)->first() ? Auth::user()->likes()->where('post_id',$post->id)->first()->like == 1 ? 'You like this post':'Like':'Like'}} </a>
      <a href="#" class="like">{{ Auth::user()->likes()->where('post_id',$post->id)->first() ? Auth::user()->likes()->where('post_id',$post->id)->first()->like == 0 ? 'You don\'t like this post':'Dislike':'Dislike'}}</a>
      @if(Auth::user() == $post->user)
        <a href="#" class="edit"  >Edit</a>

1 个答案:

答案 0 :(得分:0)

在你的控制器上,你只是在这一行返回身体:

return response()->json(['new_body'=>$post->body],500);

你应该返回完整的模型或其他属性,如下所示:

return response()->json($post, 500);

并在您的刀片中更新其他属性。