PHP - edicion registros, se queda pensando y nada

 
Vista:
sin imagen de perfil
Val: 53
Ha aumentado su posición en 3 puestos en PHP (en relación al último mes)
Gráfica de PHP

edicion registros, se queda pensando y nada

Publicado por alberto (21 intervenciones) el 03/03/2021 13:47:50
Hola buenas

alguien me podria dar una razon o ayudarme a ver porque no me funciona esta parte del codigo? la de agregar los registros y todo sin problemas, pero la parte de editar se queda ahi pensativo y nada...

este es el codigo:

HTML

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<div id="editModal" class="modal fade">
  	<div class="modal-dialog">
    	<form method="post" id="formulario_edicion">
      		<div class="modal-content">
        		<div class="modal-header">
          			<h4 class="modal-title" id="modal_title">Editar registro</h4>
          			<button type="button" class="close" data-dismiss="modal">&times;</button>
        		</div>
        		<div class="modal-body">
        			<span id="mensaje_formulario_edit"></span>
                    <div class="form-group">
                        <label>Referencia</label>
                        <input type="text" name="ref_edit" id="ref_edit" class="form-control" required data-parsley-trigger="keyup" />
                    </div>
                    <div class="form-group">
                        <label>Estanteria</label>
						<input type="text" name="est_edit" id="est_edit" class="form-control" required data-parsley-trigger="keyup" />
                    </div>
                    <div class="form-group">
                        <label>Modulo</label>
						<input type="text" name="mod_edit" id="mod_edit" class="form-control" required data-parsley-trigger="keyup" />
                    </div>
                    <div class="form-group">
                        <label>Fecha</label>
                        <input type="text" name="fecha_edit" id="fecha_edit" class="form-control datepicker" readonly required data-parsley-trigger="keyup" />
                    </div>
					<div class="form-group">
                        <label>Hora</label>
                        <input type="text" name="horas_edit" id="horas_edit" class="form-control" required data-parsley-trigger="keyup"/>
					</div>
					<div class="form-group">
                        <label>Ipn</label>
						<input type="text" name="usuario_edit" id="usuario_edit" class="form-control" required data-parsley-trigger="keyup" />
                    </div>
					<div class="form-group">
                        <label>Estado</label>
						<input type="text" name="estado_edit" id="estado_edit" class="form-control" required data-parsley-trigger="keyup" />
                    </div>
 
        		</div>
        		<div class="modal-footer">
          			<input type="hidden" name="hidden_id_edit" id="hidden_id_edit" />
          			<input type="hidden" name="action_edit" id="action_edit" value="Editar" />
          			<input type="submit" name="submit_edit" id="submit_edit" class="btn btn-success" value="Editar" />
          			<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
        		</div>
      		</div>
    	</form>
  	</div>
</div>

AJAX

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
$(document).on('click', '.boton_editar', function(){
 
    var id = $(this).data('id');
 
    $('#formulario_edicion').parsley().reset();
 
    $('#mensaje_formulario_edit').html('');
 
    $.ajax({
 
        url:"registros_action.php",
 
        method:"POST",
 
        data:{id:id, action:'fetch_single'},
 
        dataType:'JSON',
 
        success:function(data)
        {
 
            $('#ref_edit').val(data.ref);
            $('#est_edit').val(data.est);
            $('#mod_edit').val(data.mod);
            $('#fecha_edit').val(data.fecha);
            $('#horas_edit').val(data.hora);
            $('#ipn_edit').val(data.ipn);
            $('#estado_edit').val(data.estado);
 
            $('#modal_title').text('Editar registros almacenados');
 
            $('#action_edit').val('Editar');
 
            $('#submit_button_edit').val('Editar');
 
            $('#editModal').modal('show');
 
            $('#hidden_id_edit').val(id);
 
        }
 
    })
 
});
 
$('#formulario_edicion').parsley();
 
$('#formulario_edicion').on('submit', function(event){
    event.preventDefault();
    if($('#formulario_edicion').parsley().isValid())
    {
        $.ajax({
            url:"registros_action.php",
            method:"POST",
            data:new FormData(this),
            dataType:'json',
            beforeSend:function()
            {
                $('#submit_button_edit').attr('disabled', 'disabled');
                $('#submit_button_edit').val('Espera...');
            },
            success:function(data)
            {
                $('#submit_button_edit').attr('disabled', false);
                if(data.error != '')
                {
                    $('#mensaje_formulario_edit').html(data.error);
                    $('#submit_button_edit').val('Editar');
                }
                else
                {
                    $('#editModal').modal('hide');
                    $('#message').html(data.success);
                    dataTable.ajax.reload();
 
                    setTimeout(function(){
 
                        $('#message').html('');
 
                    }, 5000);
                }
            }
        })
    }
});

PHP

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
if($_POST["action"] == 'Editar')
{
    $error = '';
 
    $success = '';
 
 
 
        $data = array(
            ':referencia'	=>	$_POST["ref_edit"],
            ':estanteria'	=>	$_POST["est_edit"],
            ':modulo'		=>	$_POST["mod_edit"],
            ':fecha'		=>	date("Y-m-d", strtotime($_POST["fecha_edit"])),
            ':horas'		=>	$_POST["horas_edit"],
            ':usuario'			=>	$_POST["usuario_edit"],
            ':estado'		=>	$_POST["estado_edit"]
        );
 
 
 
 
 
        $objeto->query = "
        UPDATE registros
        SET referencia = :referencia,
        estanteria = :estanteria,
        modulo = :modulo,
        fecha = :fecha,
        hora = :horas,
        usuario = :usuario,
        estado = :estado
        WHERE id = '".$_POST['hidden_id_edit']."'
        ";
 
        $objeto->execute($data);
 
 
 
        $success = '<div class="alert alert-success">Registro Actualizado con exito por <b>'.$_SESSION['nombre'].' ( '.$_SESSION['usuario'].' )</b></div>';
 
 
 
 
    $output = array(
        'error'		=>	$error,
        'success'	=>	$success
    );
 
    echo json_encode($output);
 
}

llevo como 2h y me estoy volviendo tarumba ya

Gracias
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder