Is it possible to redirect to index method() in controller by ajax request from view.blade laravel
Guys I am working with a project. I have a view.blade (Location_details.view) file which displays the records in tabular format. I also have a search box in my view.blade. When I type a name in that search box, the change event runs in ajax and it moves to controller to search the name typed in the search box and returns the value.
My doubt is instead of returning the result, is it possible to redirect the same view.blade file with the searched output without reloading?
That is this is my index method in controller
public function index()
{
$loc=Location_details::orderBy('created_at','desc')->paginate(10);
return view('Location_details.view')->withloc($loc);
}
this is my ajax
$('#location,#area,#booth').on('keyup',function(){
$.ajax({
type : 'get',
dataType: 'json',
url : '{{URL::to('search_location_details')}}',
data:{
'location': $('#location').val(),
'area': $('#area').val(),
'booth': $('#booth').val()
},
success:function(data){
console.log(data);
var res='';
$.each (data, function (key, value) {
res +=
'<tr>'+
'<td>'+value.ven_loc+'</td>'+
'<td>'+value.ven_area+'</td>'+
'<td>'+value.ven_booth+'</td>'+
'<td>'+ "<a href='{{ route('Location_details.edit',$locs->id) }}' class='btn btn-info' style='width: 30%; float:left; margin-right:10px; '>Edit</a>"+
"<a href='{{ route('Location_details.destroy',$locs->id) }}' class='btn btn-info' style='width: 30%; '>Delete</a>"
+'</td>'+
'</tr>';
});
$('tbody').html(res);
}
});
})
I have a menu bar when I click view menu in the menu bar the index method in controller calls and displays the details through Location_details.view. After search through the ajax also once again the Location_details.view file must be called without reloading.
Is it possible?
this is my success part in ajax return
success:function(data){
console.log(data);
var res='';
$.each (data, function (key, value) {
res +=
'<tr>'+
'<td>'+value.ven_loc+'</td>'+
'<td>'+value.ven_area+'</td>'+
'<td>'+value.ven_booth+'</td>'+
'<td>'+ "<a href='{{ route('Location_details.edit',$locs->id) }}' class='btn btn-info' style='width: 30%; float:left; margin-right:10px; '>Edit</a>"+
"<a href='{{ route('Location_details.destroy',$locs->id) }}' class='btn btn-info' style='width: 30%; '>Delete</a>"
+'</td>'+
'</tr>';
});
$('tbody').html(res);
}
see instead of doing the success part in the ajax is it possible to make the view file to load once again with the searched data without reloading the page.
Why i am asking this because. I done this search in ajax return. Due to ajax return output i am suffering from pagination problem, and few problems like button placing(for edit and delete) etc. If it is possible to make the Location_details.view to load once again without reload means my whole problem will be solved and my project will be completed.
i think everyone understood the question..?
Kindly some one help please
Please or to participate in this conversation.