当我按回车键时,我希望捕获文本区域的值。问题是脚本执行没有敲定,我看不到结果。
<script type="text/javascript">
$(document).on("ready",function() {
$("#buscador_texto").keypress(function (event) {
var keycode = (event.keyCode ? event.keyCode : event.which);
//alert (keycode);
if(keycode=="13") {
//$("#tabla_usuario_individual").show();
var cod = $('#buscador_texto').val();
alert (cod);
$.ajax({
type: 'POST',
url: '<?php echo site_url("archivo/prueba"); ?>',
// data: {'cod':cod}, //enviamos el código por POST
success: function(resp) {
$("#tabla_usuario_individual").html(resp);
}
});
};
});
});
</script>
答案 0 :(得分:0)
它是$(document).ready
,而不是$(document).on("ready")
。 'ready'事件是一个jquery特定事件,只能绑定,而不是委托。
答案 1 :(得分:0)
使用 $(文档).ready(function(){而不是
)//outer variable
var answers = {
name: "hello",
age: "11"
};
var readline = require('readline');
// var rl = readline.createInterface(process.stdin, process.stdout);
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
function getInput (propertyName, question, cb) {
var answers = this; //gets the context associated to the current function
rl.question(question, function(answer) {
answers[propertyName] = answer;
rl.close();
cb();
});
}
function askForName () {
console.log(1, answers);
//sets the execution context of getInput
getInput.call(answers, "name", "What's your name? ", askForAge);
}
function askForAge () {
console.log(2, answers);
//sets the execution context of getInput
getInput.call(answers, "age", "How old are you? ", printIt);
}
function printIt () {
console.log("Hello, " + answers.name);
console.log(".. and " + answers.age + " old.");
}