mardi 11 juillet 2017

AJAX Request Show Only One, but Controller called twice

i have problem with my Project. When i submit form, Ajax request only 1 in Developers Tool Mozilla but suddenly in Server As if the request called twice (i check with add log in the code). Sometimes this problem does not happen, but more happens. Is it possible to related with stability internet connection?

Here is my ajax.

$('#GIForm').submit(function(e) {
        e.preventDefault();
    }).validate({
        submitHandler:function(form){
            if(countSave == 0){
                $.ajax({
                    url:'/new',
                    method:'post',
                    async: false,
                    data: {
                        date : $('#GIDate').val(),
                        notes : $('#GINotes').val(),
                        mswarehouse_id : $('#GISourceWarehouse').val(),
                        mstransactiontype_id : $('#GIType').val(),
                        dest_msoutlet_id : $('#GIOutlet').val(),
                        msvendor_id : $('#GIVendor').val(),
                        detail : detail
                    },
                    success: function(response){
                        $('#pleaseWaitDialog').modal('hide');
                        if(response.status=='success'){
                            var message = 'Document ' + response.description.document + ' has been saved!';
                            showAlert('',message,'success',function(e){
                                window.location.replace(laroute.route('admin.goods_issue.index'));
                            });
                        }else{
                            showAlert('',response.description,'error');
                            $('#addGIbtn').prop('disabled',false);
                            countSave = 0;
                        }
                    }, error:function(xhr,text, status){
                        $('#pleaseWaitDialog').modal('hide');
                        $('#addGIbtn').prop('disabled',false);
                        countSave = 0;
                        if(xhr.status==422){
                            showAlert('',xhr.responseJSON.join('\n'),'error');
                        }
                    }
                });
                return false;
            }
        }
    });

Here is picture from Dev. Tools Mozilla. I blur the domain. I don't know why the color status response only gray, and the response already give back status success. This problem make insert my database twice. This is screenshot from my mozilla. Response from Network Dev Tools Mozilla

Please help, I have no idea anymore



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2sKPfEX
via IFTTT

Aucun commentaire:

Enregistrer un commentaire