donkey111111 2010-01-22 00:56
浏览 48
已采纳

jQuery昨天工作。 不再

Yeah, so I have NO CLUE what happened. I've been writing an AJAX comment script and I got it working, except it doesn't work anymore. I restored it from a backup just in case I chaged anything, but no luck. It goes to the "action" of the form instead of the jQuery, even though I have return false; This leads me to believe that one of the following things is wrong: I'm not including the jQuery correctly (which I am) or I have a syntax error. Do you see anything?

$(document).ready(function() {

    $("#alert").hide();

    $('form').submit(function() {

        $("#alert").slideUp().delay(1000);
        name = $('input[name=name]').val();
        email = $('input[name=email]').val();
        timestamp = $('input[name=timestamp]').val();
        entry_title = $('input[name=entry_title]').val();
        message = $('textarea[name=message]').val();
        $.post("/scripts/ajax_comment.php", {comm_name:name, comm_email:email, comm_message:message, comm_timestamp:timestamp, comm_entry_title:entry_title}, function(data){

            switch(data) {
                case "invalid email" : $("#alert").val("").append("Invalid E-mail address.").slideDown();
                break;

                case "empty field" : $("#alert").val("").append("Make sure no fields are empty.").slideDown();
                break;

                case "error" : alert("error");
                break;

                default: $(data).appendTo("#messages").hide().slideDown().animate({ color: "#669900" }, 1000).animate({ color: "#000000" }, 1000); 
            }   
        });
        return false;
    });
}); 

SOLVED: The problem was the delay(1000);

  • 写回答

3条回答 默认 最新

  • douwenpin0428 2010-01-22 01:01
    关注

    I'm not really sure what you're doing here:

    $("#alert").slideUp().delay(1000);
    

    jQuery 1.4's $.delay() is suppose to precede an action, if I'm not mistaken. You might want to remove that or complete that line - whichever is correct for your project. I see no other problems that would prevent this from succeeding.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)