Ver Mensaje Individual
  #4 (permalink)  
Antiguo 18/06/2014, 11:40
vlademirss
 
Fecha de Ingreso: mayo-2007
Mensajes: 16
Antigüedad: 16 años, 11 meses
Puntos: 0
Respuesta: Ajax anidado ejecuta doble trile ves php

Ya lo soluciones, el problema es que por jquery hacia Onclik en el boton del formulario y también, onsubmit, es decir esccuhava cada evento, pero simplemente cambie el boton de submit a button y elimine el jquery submit, quedando asi el codigo:

POr si alguien le interese, o en algun momento tenga el mismo problemilla:

Código HTML:
$('#enviar').on('click', function() {
        var nombre = $('#nombre').val();
        $.ajax({
            type: 'POST',
            url: '../../controller/acciones_profesion.php',
            data: {accion: 1, nombre: nombre},
            success: function(data) {
                if (data = true)
                {
                    $('.good').html("Registro Exitoso...!!!");
                    $('.good').fadeIn('slow');
                    $('.datos,.option').show();
                    $('.good').fadeOut('slow');
                    $('#agregar').hide();
                    
                    $.ajax({
                            type: 'POST',
                            url: 'listarprofesion.php',
                            data:{tablas:1},
                            success: function(data) {
                                $('#datagrid').html(data);
                                
                                $('#datatable').dataTable({
                                    "sPaginationType": "full_numbers",
                                    "aaSorting": [[2, "desc"]],
                                    "bJQueryUI": false
                                });
                            }
                        });
                }
                else
                {
                    $('.bad').fadeIn('slow');
                    setTimeout(function() {
                        $('.bad').fadeOut(500);
                    }, 2000);
                }
            }
        });
    });