Jquery UI 自动完成

发布于 2024-09-25 13:25:10 字数 917 浏览 1 评论 0原文

我试图让 Jquery UI 自动完成在 div #right 中的 AJAX 加载动态字段上工作,

我不完全理解下面的代码。

$("#right").delegate(".drugName", "focus", function(){

 //attach autocomplete
$(".drugName").autocomplete({

 //define callback to format results
 source: function(req, add){

  //pass request to server
  $.getJSON("druglist.php?callback=?", req, function(data) {

   //create array for response objects
   var suggestions = [];

   //process response
   $.each(data, function(i, val){        
    suggestions.push(val.name);
   });

   //pass array to callback
   add(suggestions);
  });
 },

 });

});

但它可以在 Chrome/FF 中运行。然而,它似乎阻止了 Internet Explorer 中的 AJAX 加载,导致应用程序无法运行。

返回的错误是

   SCRIPT1028: Expected identifier, string or number  ajaxfunctions.js, line 41 character 6

控制台中的错误指的是倒数第二行的括号。

我尝试使用文档解决这个问题,但无法让它工作:-(

代码和 IE 发生了什么?

请帮忙。

I am trying to get the Jquery UI autocomplete working on AJAX loaded dynamic fields in div #right

I do not fully understand the code below.

$("#right").delegate(".drugName", "focus", function(){

 //attach autocomplete
$(".drugName").autocomplete({

 //define callback to format results
 source: function(req, add){

  //pass request to server
  $.getJSON("druglist.php?callback=?", req, function(data) {

   //create array for response objects
   var suggestions = [];

   //process response
   $.each(data, function(i, val){        
    suggestions.push(val.name);
   });

   //pass array to callback
   add(suggestions);
  });
 },

 });

});

But it works in Chrome/FF. However it seems to be killing AJAX loading in Internet Explorer causing the application to be non - functional

The error returned is

   SCRIPT1028: Expected identifier, string or number  ajaxfunctions.js, line 41 character 6

The error in the console refers to the brackets on the second last row.

I tried to work this out using the documentation, but couldnt get it to work :-(

Whats happening with the code & IE?

Pls help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

狂之美人 2024-10-02 13:25:10
//pass array to callback
 add(suggestions);
 });
}, //OK the comma here was the problem

});

成功了。 这有帮助

//pass array to callback
 add(suggestions);
 });
}, //OK the comma here was the problem

});

Got it working. this helped

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文