Javascript 发送自动完成的AJAX请求
我想在jquery中使用autocomplete,因为我正在页面上发送请求以获取数据,但这对我不起作用。请在这方面帮助我 jQueryJavascript 发送自动完成的AJAX请求,javascript,jquery,Javascript,Jquery,我想在jquery中使用autocomplete,因为我正在页面上发送请求以获取数据,但这对我不起作用。请在这方面帮助我 jQuery var addInput = function() { var inputHTML = "<input name='search' value='' class='test' maxlength='20' />"; $(inputHTML).appendTo("form#myForm"); $("input.test:last").foc
var addInput = function() {
var inputHTML = "<input name='search' value='' class='test' maxlength='20' />";
$(inputHTML).appendTo("form#myForm");
$("input.test:last").focus();
};
$("input#addButton").click(addInput);
var options = {
source: "abc.html",
minLength: 2
};
$(document).ready(function() {
$(".test" ).on('focus', function() {
$(this).autocomplete(options);
});
});
var addInput=function(){
var inputtml=“”;
$(inputtml).appendTo(“form#myForm”);
$(“input.test:last”).focus();
};
$(“输入#添加按钮”)。单击(添加输入);
变量选项={
资料来源:“abc.html”,
最小长度:2
};
$(文档).ready(函数(){
$(“.test”).on('focus',function(){
$(此).autocomplete(选项);
});
});
查看我所说的那行中的错误
var addInput = function() {
var inputHTML = "<input name='search' value='' class='test' maxlength='20' />";
$(inputHTML).appendTo("form#myForm");
$("input.test:last").focus();
};
$("input#addButton").click(addInput);
}); // This is wrong. It should be }
var options = {
source: "abc.html",
minLength: 2
};
$(document).ready(function() {
$(".test" ).on('focus', function() {
$(this).autocomplete(options);
});
});
var addInput=function(){
var inputtml=“”;
$(inputtml).appendTo(“form#myForm”);
$(“input.test:last”).focus();
};
$(“输入#添加按钮”)。单击(添加输入);
}); // 这是错误的。应该是}
变量选项={
资料来源:“abc.html”,
最小长度:2
};
$(文档).ready(函数(){
$(“.test”).on('focus',function(){
$(此).autocomplete(选项);
});
});
只需删除上面这一行,就可以:
var addInput = function() {
var inputHTML = "<input name='search' value='' class='test' maxlength='20' />";
$(inputHTML).appendTo("form#myForm");
$("input.test:last").focus();
};
$("input#addButton").click(addInput);
var options = {
source: "abc.html",
minLength: 2
};
$(document).ready(function() {
$(".test" ).on('focus', function() {
$(this).autocomplete(options);
});
});
var addInput=function(){
var inputtml=“”;
$(inputtml).appendTo(“form#myForm”);
$(“input.test:last”).focus();
};
$(“输入#添加按钮”)。单击(添加输入);
变量选项={
资料来源:“abc.html”,
最小长度:2
};
$(文档).ready(函数(){
$(“.test”).on('focus',function(){
$(此).autocomplete(选项);
});
});
如果上述操作也失败,请尝试以下操作:
$(document).ready(function() {
$(".test" ).on('focus', function() {
$(this).autocomplete({
source: "abc.html",
minLength: 2
});
});
$("input#addButton").click(function () {
var inputHTML = "<input name='search' value='' class='test' maxlength='20' />";
$(inputHTML).appendTo("form#myForm");
$("input.test:last").focus();
});
});
$(文档).ready(函数(){
$(“.test”).on('focus',function(){
$(此)。自动完成({
资料来源:“abc.html”,
最小长度:2
});
});
$(“输入#添加按钮”)。单击(函数(){
var inputtml=“”;
$(inputtml).appendTo(“form#myForm”);
$(“input.test:last”).focus();
});
});
查看我所说的那行中的错误
var addInput = function() {
var inputHTML = "<input name='search' value='' class='test' maxlength='20' />";
$(inputHTML).appendTo("form#myForm");
$("input.test:last").focus();
};
$("input#addButton").click(addInput);
}); // This is wrong. It should be }
var options = {
source: "abc.html",
minLength: 2
};
$(document).ready(function() {
$(".test" ).on('focus', function() {
$(this).autocomplete(options);
});
});
var addInput=function(){
var inputtml=“”;
$(inputtml).appendTo(“form#myForm”);
$(“input.test:last”).focus();
};
$(“输入#添加按钮”)。单击(添加输入);
}); // 这是错误的。应该是}
变量选项={
资料来源:“abc.html”,
最小长度:2
};
$(文档).ready(函数(){
$(“.test”).on('focus',function(){
$(此).autocomplete(选项);
});
});
只需删除上面这一行,就可以:
var addInput = function() {
var inputHTML = "<input name='search' value='' class='test' maxlength='20' />";
$(inputHTML).appendTo("form#myForm");
$("input.test:last").focus();
};
$("input#addButton").click(addInput);
var options = {
source: "abc.html",
minLength: 2
};
$(document).ready(function() {
$(".test" ).on('focus', function() {
$(this).autocomplete(options);
});
});
var addInput=function(){
var inputtml=“”;
$(inputtml).appendTo(“form#myForm”);
$(“input.test:last”).focus();
};
$(“输入#添加按钮”)。单击(添加输入);
变量选项={
资料来源:“abc.html”,
最小长度:2
};
$(文档).ready(函数(){
$(“.test”).on('focus',function(){
$(此).autocomplete(选项);
});
});
如果上述操作也失败,请尝试以下操作:
$(document).ready(function() {
$(".test" ).on('focus', function() {
$(this).autocomplete({
source: "abc.html",
minLength: 2
});
});
$("input#addButton").click(function () {
var inputHTML = "<input name='search' value='' class='test' maxlength='20' />";
$(inputHTML).appendTo("form#myForm");
$("input.test:last").focus();
});
});
$(文档).ready(函数(){
$(“.test”).on('focus',function(){
$(此)。自动完成({
资料来源:“abc.html”,
最小长度:2
});
});
$(“输入#添加按钮”)。单击(函数(){
var inputtml=“”;
$(inputtml).appendTo(“form#myForm”);
$(“input.test:last”).focus();
});
});
我在这里看到了什么问题:
我可以在这里看到一个额外的结尾:
$("input#addButton").click(addInput);
}); // <----------------------------------this one don't know which one
//------------------------------------but it should not have to be here.
$(“输入#添加按钮”)。单击(添加输入);
}); // 我在这里看到了什么问题:
您正在尝试在dom就绪之前绑定事件
你有一个额外的未知结束标记
您在一个元素上绑定一个事件,该元素不在DOM中,而是在一些用户交互之后绑定的
我可以在这里看到一个额外的结尾:
$("input#addButton").click(addInput);
}); // <----------------------------------this one don't know which one
//------------------------------------but it should not have to be here.
$(“输入#添加按钮”)。单击(添加输入);
}); // 你能解释一下到底是什么不起作用吗?控制台上有输出吗?请同时发布所有相关代码。请求未发送到我的abc页面。html@PoojaDubey你有一个错误。让我加上答案。我已经做了同样的事情,但那不是working@PoojaDubey我已经更新了我的答案。请检查一下,你能解释一下到底是什么不起作用吗?控制台上有输出吗?请同时发布所有相关代码。请求未发送到我的abc页面。html@PoojaDubey你有一个错误。让我加上答案。我已经做了同样的事情,但那不是working@PoojaDubey我已经更新了我的答案。请查收好吗?