My dialog in ajax only works once

0

Hi everyone, I'm trying to update information in a crud which I reload every 2 seconds with the .load function of jquery I thought there would be no problem since the dialog opens and the form is not affected by the recharge, but for some reason only the first time my dialog updates information, this is my code:

$(document).ready(function () {
    //editamos datos del usuario
    $(".editar").on('click', function () {
        var orden_de_compra = $(this).attr('id');

        $("<div class='edit_modal'><form name='edit' id='edit' method='post' action='editar_estatus.php'>"+

          "<select name='estatus' required><option value=''>seleccione un estatus</option><option>Embarcado</option> <option>Almacen</option><option>N/A</option></select><br/>"+
          "<input type='hidden' name='orden_de_compra' value="+orden_de_compra+">"+

            "<br/></form> </div>").dialog({
                resizable:false,
                title:'Editar usuario.',
                height:300,
                width:350,
                modal:true,
                buttons:{
                    "Editar":function () {
                        $.ajax({
                            url : $('#edit').attr("action"),
                            type : $('#edit').attr("method"),
                            data : $('#edit').serialize(),
                            complete:function () {
                                $('.edit_modal').dialog("close");
                                $("<div class='edit_modal'>El usuario fué editado correctamente</div>").dialog({
                                    resizable:false,
                                    title:'Usuario editado.',
                                    height:200,
                                    width:450,
                                    modal:true
                                });

                            }, error:function (error) {
                                $('.edit_modal').dialog("close");
                                $("<div class='edit_modal'>Ha ocurrido un error!</div>").dialog({
                                    resizable:false,
                                    title:'Error editando!.',
                                    height:200,
                                    width:450,
                                    modal:true
                                });
                            }
                        });
                        return false;
                    },
                    Cancelar:function () {
                        $(this).dialog("close");

                    }
                }
            });
    });


});

The console throws this error:

jquery-1.11.0.min.js:4 [Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.
    
asked by Daniel Treviño 16.04.2018 в 07:55
source

0 answers