how can I pass the value of my litbox in ajax ==

0
function insertar() {


    var data = {
        objpersona: {

            licencia: $("#Licencia").val(),
            categoriaid: $("#categoria").val(),
            p_ci: $("#carnet").$(this).val()
        }
    }

    $.ajax({

        type: "POST",
        url: "Conductor.aspx/Registrapersona",
        data: JSON.stringify(data),
        contentType: "application/json; charset=utf-8",
        dataType: "json",

        success: function (data) {

            $('#myModal').modal('hide'),
                $('#tablapersona').show()
          ///  fillLimpiar();
            $('#tx').val("");
            location.reload();



            console.log("hola")

        },
        error: function (msg) {
            console.log(msg);
            alert(msg);
        }


    }).done(function (info) {
        console.log(info);
    })
}
    
asked by Jose Clavijo 17.06.2018 в 16:50
source

1 answer

0

I do not understand what is really your doubt but some advice, if you want to use promises, inside the ajax object you do not need to pass the functions success and error since done and fail are equivalent

const request = $.ajax({
    type: "POST",
    url: "Conductor.aspx/Registrapersona",
    data: JSON.stringify(data),
    contentType: "application/json; charset=utf-8",
    dataType: "json"
});
request.done(function (result) {
   $('#myModal').modal('hide');
   $('#tablapersona').show();
   $('#tx').val("");
   location.reload();
});
request.fail(function (msg) {
  console.log(msg);
  alert(msg);    
});

also exists always, I would appreciate it if you explain a little more what is your doubt and put more html code.

A slaudo

    
answered by 18.06.2018 в 10:05