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 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛