Foros del Web » Programando para Internet » Javascript » Frameworks JS »

Enviar Datos via POST

Estas en el tema de Enviar Datos via POST en el foro de Frameworks JS en Foros del Web. Hola gente, estoy haciendo un formulario, pero no me envia los datos. Tengo el siguiente codigo: Código PHP: $(function(){      //original field values      var  field_values  = { ...
  #1 (permalink)  
Antiguo 14/07/2013, 17:08
 
Fecha de Ingreso: diciembre-2010
Mensajes: 160
Antigüedad: 13 años, 4 meses
Puntos: 1
Enviar Datos via POST

Hola gente, estoy haciendo un formulario, pero no me envia los datos. Tengo el siguiente codigo:

Código PHP:
$(function(){
    
//original field values
    
var field_values = {
            
//id        :  value
            
'nombre'  'Nombre',
            
'actividad'  'Actividad',
            
'telefono' 'Telefono',
            
'correo'  'Correo electronico',
            
'skype'  'Skype',

    };


    
//inputfocus
    
$('input#nombre').inputfocus({ valuefield_values['nombre'] });
    $(
'input#actividad').inputfocus({ valuefield_values['actividad'] });
    $(
'input#telefono').inputfocus({ valuefield_values['telefono'] });
    $(
'input#skype').inputfocus({ valuefield_values['skype'] });
    $(
'input#correo').inputfocus({ valuefield_values['correo'] });




    
//reset progress bar
    
$('#progress').css('width','0');
    $(
'#progress_text').html('0% Complete');

    
//first_step
    
$('form').submit(function(){ return false; });
    $(
'#submit_first').click(function(){
        
//remove classes
        
$('#first_step input').removeClass('error').removeClass('valid');

        
//ckeck if inputs aren't empty
        
var fields = $('#first_step input[type=text]');
        var 
error 0;
        
fields.each(function(){
            var 
value = $(this).val();
            if( 
value.length<|| value==field_values[$(this).attr('id')] ) {
                $(
this).addClass('error');
                $(
this).effect("shake", { times:}, 50);

                
error++;
            } else {
                $(
this).addClass('valid');
            }
        });

        if(!
error) {
            if( $(
'#username').val() == "") {
                    $(
'#first_step input[type=password]').each(function(){
                        $(
this).removeClass('valid').addClass('error');
                        $(
this).effect("shake", { times:}, 50);
                    });

                    return 
false;
            } else {
                
//update progress bar
                
$('#progress_text').html('33% Complete');
                $(
'#progress').css('width','113px');

                
//slide steps
                
$('#first_step').slideUp();
                $(
'#second_step').slideDown();
            }
        } else return 
false;
    });


    $(
'#submit_second').click(function(){
        
//remove classes
        
$('#second_step input').removeClass('error').removeClass('valid');

        var 
emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,4}$/;
        var 
fields = $('#second_step input[type=text]');
        var 
error 0;
        
fields.each(function(){
            var 
value = $(this).val();
            if( 
value.length<|| value==field_values[$(this).attr('id')] || ( $(this).attr('id')=='email' && !emailPattern.test(value) ) ) {
                $(
this).addClass('error');
                $(
this).effect("shake", { times:}, 50);

                
error++;
            } else {
                $(
this).addClass('valid');
            }
        });

        if(!
error) {
                
//update progress bar
                
$('#progress_text').html('66% Complete');
                $(
'#progress').css('width','226px');

                
//slide steps
                
$('#second_step').slideUp();
                $(
'#third_step').slideDown();
        } else return 
false;

    });


    $(
'#submit_third').click(function(){
        
//update progress bar
        
$('#progress_text').html('100% Complete');
        $(
'#progress').css('width','339px');

        
//prepare the fourth step
        
var fields = new Array(
            $(
'#username').val(),
            $(
'#password').val(),
            $(
'#email').val(),
            $(
'#firstname').val() + ' ' + $('#lastname').val(),
            $(
'#age').val(),
            $(
'#gender').val(),
            $(
'#country').val()
        );
        var 
tr = $('#fourth_step tr');
        
tr.each(function(){
            
//alert( fields[$(this).index()] )
            
$(this).children('td:nth-child(2)').html(fields[$(this).index()]);
        });

        
//slide steps
        
$('#third_step').slideUp();
        $(
'#fourth_step').slideDown();
    });


       $(
'#submit_fourth').click(function(){

        $.
ajax({
        
type"POST",
        
url"ajax.php",
        
data"nombre="+$('#nombre').val()+"&actividad="+$('#actividad').val()+"&telefono="+$('#telefono').val()+"&correo="+$('#correo').val()+"&skype="+$('#skype').val()+"&ganardinero="+$('#ganardineri').val()+"&ganard="+$('#ganard').val()+"now="+$('#now').val(),
        
success: function(response) { alert('it worked!'); }

    });


});

}); 
Funcionan todos los efectos ajax, lo unico que no me funciona es enviar los datos, ya vi varias cosas y probe muchas y sigue sin funcionar.

el codigo para enviar es este:

Código PHP:
$('#submit_fourth').click(function(){

        $.
ajax({
        
type"POST",
        
url"ajax.php",
        
data"nombre="+$('#nombre').val()+"&actividad="+$('#actividad').val()+"&telefono="+$('#telefono').val()+"&correo="+$('#correo').val()+"&skype="+$('#skype').val()+"&ganardinero="+$('#ganardineri').val()+"&ganard="+$('#ganard').val()+"now="+$('#now').val(),
        
success: function(response) { alert('it worked!'); }

    }); 
Que estoy haciendo mal? muchas gracias por la ayuda!

Etiquetas: ajax, formulario, funcion, html, input, javascript, php, post
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 16:46.