I am using laravel 4.2 and trying to update data using ajax, but in ajax redirect url does not work for me. Because I use URL: an action like,
$.ajax({
type: 'POST',
dataType: 'json',
url : "store",
data: { title: postTitle['post-title']['value'], body: postContent['post-body']['value'] },
success: function(data) {
if(data.success === false)
{
$('.error').append(data.message);
$('.error').show();
} else {
$('.success').append(data.message);
$('.success').show();
setTimeout(function() {
window.location.href = "{{ URL::action('PostsController@index') }}";
}, 2000);
}
},
error: function(xhr, textStatus, thrownError) {
alert('Something went wrong. Please Try again later...');
}
});
I do not know why it does not work. please help me.
source
share