使用 Jquery/AJAX/Javascript 搜索、排序、分页和过滤 DIV

发布于 2024-12-25 04:10:49 字数 480 浏览 0 评论 0原文

我正在开发项目的前端,稍后再开发后端。不过我遇到了障碍。我有一个 DIV 列表(也希望它们是可折叠的),它们应该显示给定邮政编码周围的各种公寓。问题是,我不知道去哪里寻找这些东西:

  • 首先,我希望按名称或排名对这些 div 进行排序。
  • 其次,我 希望能够搜索这些结果并丢弃那些 他们不想要,即我输入 A,所有以 A 开头的公寓 字母 BZ 在列表中消失。我认为在 A 之后的 p 中,都是 Aa-Az 字母从列表中消失,等等。
  • 第三,我应该使用 jQuery 对结果进行分页还是应该使用 PHP?
  • 最后,我还有一个过滤盒。我想做与上面相同的事情,除了不同的可选选项(使用 AJAX 即时)。用户选择,1至3居室公寓,无宠物, 并点击过滤器...繁荣,具有价值的公寓列表。

有什么可以使用 jQuery/Javascript 来加速这个过程,当 Javascript 被禁用时,这个过程也会降低?我知道这听起来很多,但任何帮助将不胜感激。

I'm working on the front-end of my project and doing the back-end later. I've ran into a snag though. I have a list of DIVs (want them to be collapsible as well) that are suppose to show various apartments around a given zip code. Problem is, I don't know where to go to look for these things:

  • Firstly, I wish to sort these divs by name or ranking.
  • Secondly, I
    want to be able to search these results and toss out the ones that
    they do not want, i.e. I type in A, all apartments that begin with
    letters B-Z disappear in the list. I think in p after A, all Aa-Az
    letters disappear from the list, etc.
  • Thirdly, should I use jQuery to paginate my results or should I use PHP instead?
  • Lastly, I have a filter box. I want to do the same as above except with different selectable options (on the fly using AJAX). User selects, 1 to 3 bedroom apartments, no pets,
    and hits filter... boom, list of apartments with values.

Is there anything that I can use using jQuery/Javascript to speed up this process that also degrades when Javascript's disabled? I know this sounds like a lot, but any help would be greatly appreciated.

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

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

发布评论

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

评论(1

°如果伤别离去 2025-01-01 04:10:49

为了让它在没有 javascript 的情况下工作,并且仍然像你想要的那样运行,我想你必须在纯旧的 html 中构建它(带有表单帖子/链接),然后添加 jquery ajax 功能,以使其在启用 javascript 时更漂亮、更快。

如果我这样做,我会使用返回整个页面的表单帖子来构建它(当禁用 javascript 时),并在页面加载时添加 jquery 事件以防止默认表单帖子,而是使用 ajax post 仅部分加载页面并应用转换影响。

最后一件事,如果您有大量数据要在页面上显示,请使用数据库级别的分页和排序,仅返回页面的可见内容。无论有没有 javascript,这都可以工作,并且是可扩展的(有很多结果,在 javascript 中变得难以管理)

Well for this to work without javascript, and still behave like you want, i guess you have to build this in pure old html (with form post's / links) and then add jquery ajax functionality to make it prettier and faster when javascript is enabled.

If i were doing this, i would build it with form post's that return the whole page (when javascript is disabled) and add jquery events on page load to prevent default form post and instead use ajax post to only partial load your pages and aply transition effects.

One last thing, if you have a lot of data to show on page use pagination and sorting at database level, return only the visible content of your page. This will work with and without javascript, and is scalable (with lots of results it becomes unmanageable to it in javascript)

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