You cannot use ajax posting and also refresh the page - its pointless. Do one or the other.
Oct 4, 2017
2
Level 2
save old data after refresh page with ajax
HI guys. I have select box and I use on change method with ajax. This is my select box
<select class="select js-delivery" name="delivery_id">
<option selected disabled>Choose delivery type</option>
@foreach($deliveries as $delivery)
<option value="{{$delivery->id}}">{{ $delivery->title }}</option>
@endforeach
</select>
and here my ajax.
$(document).on('change', '.js-delivery', function(e){
delivery.show();
var delivery_id = $(this).val();
$.ajax({
type:'GET',
url:'get/delivery',
data: {'id':delivery_id},
success:function(data){
var type = $('.delivery-type');
type.html(data.title);
},
error:function(data){
console.log('error');
}
});
});
After this I submitted form and page refreshed. But when I was laravel errors I am losing select box value. How can I save old data?
Please or to participate in this conversation.