duanmu2015 2011-10-25 19:40
浏览 53
已采纳

为什么这个jQuery AJAX不起作用?

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? ^^^^^

  • 写回答

1条回答 默认 最新

  • doumen5491 2011-10-25 19:50
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 CSS通配符清除内外边距为什么可以覆盖默认样式?
  • ¥15 SPSS分类模型实训题步骤
  • ¥15 求解决扩散模型代码问题
  • ¥15 工创大赛太阳能电动车项目零基础要学什么
  • ¥20 limma多组间分析最终p值只有一个
  • ¥15 nopCommerce开发问题
  • ¥15 torch.multiprocessing.spawn.ProcessExitedException: process 1 terminated with signal SIGKILL
  • ¥15 QuartusⅡ15.0编译项目后,output_files中的.jdi、.sld、.sof不更新怎么解决
  • ¥15 pycharm输出和导师的一样,但是标红
  • ¥15 想问问富文本拿到的html怎么转成docx的