简体   繁体   中英

Why doesn't this jQuery AJAX work?

I don't understand why this form wont send.

The coding is very long and I don't think it would be good idea to post all of it here.

  • Link to form here
  • Link to Script here

    I just tried loading the PHP file in browser and it wouldn't work. I will save it as a .txt file so you can view it. It will be @ ......multiform/post.txt

On top of that, how would I send the entire form instead of stating all the values for the 'data' bit:

   $.ajax({
        type: 'POST',
        url: 'post.php',
        data: {subject:options.subject, name:$(this_id_prefix+'#adycustlname').val(),     email:$(this_id_prefix+'#email').val(), message:$(this_id_prefix+'#zip').val()},
        success: function(data){

Also ignore the success: function(data){ section, this form is going to be put in a slide panel so that is for what the slider should do after. I have a feeling it is wrong, but the main issue is to get the form to send.

EDIT

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

               //send information to server

       $.ajax({
            type: 'POST',
            url: 'post.php',
            data: $('#bob').serialize(),
            success: function(data){
                        $(this_id_prefix+'#loading').css({display:'none'}); 
                        if( data == 'success') {
                            $(this_id_prefix+'#callback').show().append(options.recievedMsg);
                            if(options.hideOnSubmit == true) {
                                //hide the tab after successful submition if requested
                                $(this_id_prefix+'#contactForm').animate({dummy:1}, 2000).animate({"marginLeft": "-=450px"}, "slow");
                                $(this_id_prefix+'div#contactable_inner').animate({dummy:1}, 2000).animate({"marginLeft": "-=447px"}, "slow").animate({"marginLeft": "+=5px"}, "fast"); 
                                $(this_id_prefix+'#overlay').css({display: 'none'});    
                            }
                        } else {
                            $(this_id_prefix+'#callback').show().append(options.notRecievedMsg);
                            setTimeout(function(){
                                $(this_id_prefix+'.holder').show();
                                $(this_id_prefix+'#callback').hide().html('');
                            },2000);
                        }
                    },
  error:function(){
                        $(this_id_prefix+'#loading').css({display:'none'}); 
                        $(this_id_prefix+'#callback').show().append(options.notRecievedMsg);
                                        }
});     




        alert('Data sent');
    });   
        } else return false;  
        alert('Fail');

    });

^^^^^ Why wont the above code work? ^^^^^

At the end of your script you have to replace

$('#submit_fourth').click(function(){
    //send information to server
    alert('Data sent');
});

with the correct URL to send to.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM