Laravel return a view in an Ajax response
They are not working for you because they return a JSON response and not an html one. You should return the view directly, without the render method call.
Try this
return view('pages.your_page');
or
return view('pages.your_page')->render();
Laravel 5.2 - Return view from controller after ajax request
SOLVED
Not the most elegant solution but what I did was set the array with errors as an session variable and get that session var in the specific controller I need.
Controller
$request->session()->put('importErrors',$erro);
$response = array('status' =>'success','url' => '/ListarContactos/'.$idList);
return response()->json($response);
JavaScript
$('#importar').submit(function(e) {
e.preventDefault();
fdata=preparePostData();
$.ajax({
type:'POST',
url: $(this).prop('action'), // url, from form
data:fdata,
processData: false,
contentType: false,
success:function(data) {
if(data.status=='success'){
window.location.replace(data.url);
}
}
});
}); // end form.submit
XPTOController
$errorArray= $request->session()->get('importErrors');
After using it you can destroy the session variable or keep it(depending if you need it or not).
Related Topics
How to Check If Page Exists Using JavaScript
React Router with Optional Path Parameter
Uncaught Typeerror: Cannot Read Property 'Msie' of Undefined - Jquery Tools
How to Keep the Menu State on Page Reload
How to Escape a String Inside JavaScript Code Inside an Onclick Handler
Where Should I Declare JavaScript Files Used in My Page? in <Head></Head> or Near </Body>
Jquery Sort Elements Using Data Id
JavaScript Code Works in Jsfiddle and But Not in the Browser
How to Set Preview of Video File, Selecting from Input Type='File'
Use a JavaScript Array to Fill Up a Drop Down Select Box
Download PDF File Using Jquery Ajax
Javascript: How to Dynamically Create Nested Objects Using Object Names Given by an Array
Set Cursor at a Length of 14 Onfocus of a Textbox
Save JSON String to Client Pc (Using HTML5 API)
Bootstrap V2 Dropdown Navigation Not Working on Mobile Browsers