Notice: Undefined index when sending arrays by ajax

1

something strange happens to me, I used the same code in another part of my project and it works perfectly but when passing array by ajax I am receiving "notice Undefined index" I have used different variants that I have found to pass arrays correctly using AJAX but none seems to work, suggestions?

JS code

$(document).on('click', '#verificarImp', function(){
var r = $('table tr').length;
var item1 = [];
var item2 = [];
var item3 = [];
var w;

for (w = 1; w < r ; w++) {
item1[w-1] = document.getElementById('idCodigo_'+w).value;
item2[w-1] = document.getElementById('idDetalle_'+w).value;
item3[w-1] = document.getElementById('idCantidad_'+w).value;
}
  $.ajax({
     url:"presolicitud_me.php",
     method:"POST",
     data:{item1:item1, item2:item2, item3:item3},
     success:function(resultado){
     if(resultado){
       alert(resultado);
     }
     }
  });
});

by clicking on a button, it collects the values of a dynamic table in arrays and sends them to the page "presolicitud_me.php"

PHP code

<?php
$codigo = $_POST['item1'];
$detalle = $_POST['item2'];
$cantidad = $_POST['item3'];

var_dump($detalle);
?>

Another rarity is that if I put an alert to success I can see correctly the PHP code execution but the page as such is not working.

    
asked by KanguroAndino 23.08.2018 в 04:56
source

0 answers