Laravel 5.2 & AJAX - Display success message after redirect
<p>I'm creating a CRUD system in L5.2 and am using Bootstrap Modal to display forms. I've used <a href="https://github.com/adamwathan/bootforms" rel="noreferrer">BootForms</a> and <a href="https://github.com/JerseyMilker/Laravel-Bootstrap-Modal-Form" rel="noreferrer">Laravel Bootstrap Modal Form</a> to validate forms and display error messages inside Modal without closing it. </p>

<p>Basically I'm opening Add / Edit forms inside a modal on same page, the form validation is done inside Modal and once everything is okay the data is being inserted in database and the modal closes. After that the page refreshes and shows updated data.</p>

<p>Everything is working fine, except in case of success I am not able to display a success message on my page. </p>

<p>Following is my code:</p>

<p><strong>AJAX</strong></p>

<pre><code>$.ajax({
    type: "POST",
    url: url,
    data: data,
    dataType: 'json',
    cache: false,
    contentType: contentType,
    processData: false

// Response.
}).always(function(response, status) {

    // Reset errors.
    resetModalFormErrors();

    // Check for errors.
    if (response.status == 422) {
        var errors = $.parseJSON(response.responseText);

        // Iterate through errors object.
        $.each(errors, function(field, message) {
            console.error(field+': '+message);
            var formGroup = $('[name='+field+']', form).closest('.form-group');
            formGroup.addClass('has-error').append('&lt;p class="help-block"&gt;'+message+'&lt;/p&gt;');
        });

        // Reset submit.
        if (submit.is('button')) {
            submit.html(submitOriginal);
        } else if (submit.is('input')) {
            submit.val(submitOriginal);
        }

    // If successful, reload.
    } else {
        location.reload();
    }
});
</code></pre>

<p><strong>Controller:</strong></p>

<pre><code>public function store(CustomerRequest $request)
{
    Customer::create($request-&gt;all());

    return redirect('customers')
        -&gt;with('message', 'New customer added successfully.')
        -&gt;with('message-type', 'success');
}
</code></pre>

<p><strong>View:</strong> (to display success message)</p>

<pre><code>@if(Session::has('message'))
    &lt;div class="alert alert-{{ Session::get('message-type') }} alert-dismissable"&gt;
        &lt;button aria-hidden="true" data-dismiss="alert" class="close" type="button"&gt;×&lt;/button&gt;
        &lt;i class="glyphicon glyphicon-{{ Session::get('message-type') == 'success' ? 'ok' : 'remove'}}"&gt;&lt;/i&gt; {{ Session::get('message') }}
    &lt;/div&gt;
@endif
</code></pre>

<p>You can see in case of success AJAX just reloading the page, I want it to redirect to the page specified in Controller function and display that success message.</p>