I do not get the values from AJAX

0

I am trying to send some values from AJAX to my controller but they do not reach me. I have looked at some web pages but I have not found the solution to this problem.

In the jQuery tag:

function add_tipoDoc() {
  var idTi = document.getElementById("tipoDocumental.idTipoDocumental").value;
  var capa = document.getElementById("divlistar");
  $.ajax({

    type: "get",
    dataType: 'text',
    url: "select_tipodoc.htm",
    data: {
      'valorP': idTi
    },
    success: function(response) {
      var z = JSON.parse(response);
      $("#tableindice").find("tr").remove();
      for (var i = 0; i < z.length; i++) {
        var htfil = "<hr/><tr>";
        var htcol1 = "<td>" + "<label name='nombres' for='normal' class='control-label'>" + z[i] + "</label></td>";
        var htcol2 = "<td>" + "<input name='valores' type='text' cssClass='form-control' placeholder='Ingrese Valor'/></td>";
        var htfil2 = "</tr>";
        var htfin = htfil + htcol1 + htcol2 + htfil2;
        $('#tableindice').append(htfin);
      }
  },
  //...

In the HTML:

<div id="divlistar">
  <table id="tableindice">
  </table>
</div>
    
asked by Kevin Castaño 24.05.2017 в 15:19
source

2 answers

0

I think the problem is the url of ajax , I think that your url is not written badly it is not a html

function add_tipoDoc() {
  var idTi = document.getElementById("tipoDocumental.idTipoDocumental").value;
  var capa = document.getElementById("divlistar");
  $.ajax({
        type: "get",
        dataType: 'text',
        url: "select_tipodoc.html",
        data: {
          'valorP': idTi
        },
        success: function(response) {
          var z = JSON.parse(response);
          $("#tableindice").find("tr").remove();
          for (var i = 0; i < z.length; i++) {
            var htfil = "<hr/><tr>";
            var htcol1 = "<td>" + "<label name='nombres' for='normal' class='control-label'>" + z[i] + "</label></td>";
            var htcol2 = "<td>" + "<input name='valores' type='text' cssClass='form-control' placeholder='Ingrese Valor'/></td>";
            var htfil2 = "</tr>";
            var htfin = htfil + htcol1 + htcol2 + htfil2;
            $('#tableindice').append(htfin);
          }

        },
    
answered by 24.05.2017 в 15:31
0

Friend, I think first of all it would be good if you shared part of your back-end to better understand what could be wrong. Greetings.

    
answered by 24.05.2017 в 23:32