如何将SQL数据插入自动完成的jQuery列表中

发布于 2025-01-22 20:58:55 字数 333 浏览 2 评论 0原文

我试图在snippet中修改代码:

https://api.jqueryui.com/autocomplete/autocomplete/

允许我将自动完成列表与SQL查询的结果填充而不是静态。

它将生活在ASP.NET C#页面上。

我的jQuery不太流利,所以也许这很容易,但是任何帮助都将不胜感激。

tnx 〜J

I was trying to modify the code in the snippet:

https://api.jqueryui.com/autocomplete/

to allow me to have the autocomplete list populated with the result of an SQL query instead of static.

It's gonna live on an asp.net c# page.

I'm not very fluent in jQuery so maybe it's an easy one, but any help would be greatly appreciated.

tnx
~j

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

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

发布评论

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

评论(1

故事↓在人 2025-01-29 20:58:55

您想通过 source选项。这是超级简化的片段:

$( ".selector" ).autocomplete({
  source: "https://mywebsite.com/getData.php"
});

每次用户在自动完成中键入时,请发送请求,然后发送QueryString发送搜索术语,例如用户类型'Java':https:// mywebsite .com/getData.php?term = java

You want to get the data via the source option. Here's super simplified snippet:

$( ".selector" ).autocomplete({
  source: "https://mywebsite.com/getData.php"
});

Everytime the user types in the autocomplete, a request is sent with a querystring to send the search term, like if the user types 'java': https://mywebsite.com/getData.php?term=java

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