简体   繁体   English

Ajax的jQuery自动完成问题-TypeError:this.source不是函数

[英]jQuery autocomplete problems with ajax - TypeError: this.source is not a function

I'm using the jQueryUI autocomplete function it works fine with data from a local variable but when using data from a $.get request i'm getting the following error: TypeError: this.source is not a function. 我正在使用jQueryUI自动完成功能,它可以很好地处理来自本地变量的数据,但是当使用来自$ .get请求的数据时,出现以下错误:TypeError:this.source不是函数。 If I remove $(function(){ in the code there is no error but still no data in autocomplete. 如果我在代码中删除$(function(){,没有错误,但自动完成中仍然没有数据。

Content in: index.html
<script>
$(function(){
var ajaxData;
$.get('ajaxdata.html', function(data) {
$('.result').html(data);
console.log('Load was performed.'+data);
ajaxData = data;
});

var localData = ['ActionScript','AppleScript','Scheme'];
$( "#tags" ).autocomplete({
//source: localData //working
source: ajaxData //not working
});
});
</script>
<input id="tags">

Content in: ajaxdata.html
['ActionScript','AppleScript','Scheme']

For example: 例如:

// use document ready
$(document).ready(function(){
  $.get('ajaxdata.html', function(data) {
    $('.result').html(data);

    console.log('Load was performed.'+data);

    $( "#tags" ).autocomplete({
      source: data
    });
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 jquery 自动完成 this.source 不是函数错误 - jquery autocomplete this.source is not a function error 在jquery的自动完成功能中得到错误“ this.source不是一个功能。” - Getting the error in the autocomplete function of the jquery “this.source is not a function.” 实现自动完成时出现“this.source 不是函数”错误 - “this.source is not a function” error while implementing autocomplete jQueryUI 自动完成错误:this.source 不是函数 - jQueryUI Autocomplete error: this.source is not a function 未被捕获的TypeError:this.source不是功能coffeescript错误 - Uncaught TypeError: this.source is not a function coffeescript error this.source 不是函数。 jquery-ui 错误 - this.source is not a function. Error with jquery-ui 使用Bloodhound-this.source的Typeahead js不是一个函数 - Typeahead js with Bloodhound- this.source is not a function jQuery Autocomplete(1.8.5) - 未捕获的TypeError,属性'source'不是函数 - jQuery Autocomplete (1.8.5) - Uncaught TypeError, property 'source' is not a function 如何在JQuery UI自动完成中使用source:function()…和AJAX - How to use source: function()… and AJAX in JQuery UI autocomplete jQuery Uncaught TypeError:$(…).autocomplete不是函数 - jQuery Uncaught TypeError: $(…).autocomplete is not a function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM