Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jquery中的keydown问题_Jquery_Ajax_Keydown - Fatal编程技术网

jquery中的keydown问题

jquery中的keydown问题,jquery,ajax,keydown,Jquery,Ajax,Keydown,请帮忙。我在使用jquerykeydown获取要发布到数据库的数据时遇到了一些困难 在脚本中添加if(e.which==13){之后,没有数据进入数据库,但我从Ajax部分收到了一条完全肯定的消息 如果我删除e.which==13部分,它会工作,但会将我键入的每个字母添加到数据库中一个单独的行中 我到底做错了什么?如果有区别的话,我正在使用cakephp - 你应该更喜欢我们.on()而不是.bind()。console.log(e.which)的结果是什么?以及console.log(e.ke

请帮忙。我在使用jquerykeydown获取要发布到数据库的数据时遇到了一些困难

  • 在脚本中添加if(e.which==13){之后,没有数据进入数据库,但我从Ajax部分收到了一条完全肯定的消息
  • 如果我删除e.which==13部分,它会工作,但会将我键入的每个字母添加到数据库中一个单独的行中 我到底做错了什么?如果有区别的话,我正在使用cakephp
  • -


    你应该更喜欢我们
    .on()
    而不是
    .bind()
    console.log(e.which)
    的结果是什么?以及
    console.log(e.keyCode)的结果是什么
    ?后端运行什么将数据输入数据库,一个PHP页面?为什么要将
    注释添加到URL…它可能有空格,对吗?为什么不在ajax中将其作为参数发送(而不是在URL中)并从后端的参数中读取它?Herbertp the.on.Thankshase,您的建议似乎是最好的方法。您能说明如何做到这一点吗,谢谢
    
    $(document).ready(function() {
        $('#notify').bind("keydown", function(e){
            if ( e.which == 13 ) {
    
                var notes  = $('.note').val();  
    
                var targeturl = 'http://www.domain.com/notifications/index/33/'+notes;  
                //alert(targeturl);
    
                $.ajax({    
                    dataType: "html",
                    type: "POST",
                    evalScripts: true,              
                    url: targeturl,     
                    complete: function () {
                        // Handle the complete event
                        var result = "Thanks for update your fans";
                        $("#thanksfornotes").fadeOut("slow").html(result);
                    }     
                })
    
            }
    
        });
    });