1

I want to display the blade form after ajax success but the result is not rendered properly ...

CategoryController.php

public function edit($id)
{
    $categories = Category::find( $id );

    return view( 'modules.category._form', compact( 'categories' ));
}

_form.blade.php

{!! Form::model($categories, ['url' => route('categories.update', $categories->id), 'method' => 'put']) !!}
<div class="form-group{{ $errors->has('title') ? ' has-error' : '' }}">
{!! Form::label('title','Title') !!}
{!! Form::text('title', null, ['class'=>'form-control','placeholder'=>'Enter title here']) !!}
@if ($errors->has('title'))
<span class="help-block">{{ $errors->first('title') }}</span>
@endif
</div>
<div class="form-group form-actions">
<button type="submit" class="btn btn-sm btn-primary"><i class="fa fa-angle-right"></i> Update</button>
<button type="reset" class="btn btn-sm btn-warning"><i class="fa fa-repeat"></i> Reset</button>
</div>
{!! Form::close() !!}

view

<div id="form-edit"></div>

<script>
$(function(){    
$('.edit').click(function(){
            var id = $(this).data('id');
             var form_action = $('#edit'+id).data('href');
             $.ajax({
                type: 'GET',
                url: form_action,
                data: { '_method':'PUT','_token':$('meta[name=csrf-token]').attr('content'),'id':id },
                success: function(result){
                    $('#form-edit').html(result);
                    }
             });
          });
});
</script>

Result:

result

Form HTML Laravelcollective not render

How to fix itu ? ...

Anan Andi
  • 11
  • 3
  • success: function(result){ $('#form-edit').html(result); } use each to go over the result and append it to the target html element – Indra Apr 13 '18 at 12:21

0 Answers0