javascript - SO是如何动态获取它的Tag的呢?

标签 javascript jquery ajax stack-overflow

<分区>

当您提问时,stackoverflow 如何将其可用标签加载到下面的标签输入中?他们是在页面加载时填充可用标签,还是在每次用户输入或用户按键时发出请求?我计划在我的应用程序中实现相同的方式,但我不知道如何实现这一目标。

最佳答案

他们绝对不会在页面加载时加载所有可用的标签,因为有太多的标签。我在 Firefox 的 Web 控制台下运行了一个快速测试,他们似乎使用 AJAX 执行 JSON 请求。一个例子是:

https://stackoverflow.com/filter/tags?q=visual&newstyle=true&_=1359502308905

结果响应:

[{"Name":"c#","Synonyms":"visual-c#","Count":409187,"Excerpt":"C# is a multi-paradigm programming language encompassing strong typing, imperative, declarative, functional, generic, object-oriented (class-based), and component-oriented programming disciplines. It was developed by Microsoft for use with their .NET framework and later approved as a standard by Ecma (ECMA-334) and ISO (ISO/IEC 23270:2006). It is now also available on different platforms (Android, Linux, iOS) via the MONO project."},{"Name":"visual-studio-2010","Synonyms":"visual-studio-2010-rtm","Count":30434,"Excerpt":"Visual Studio is an integrated development environment (IDE) from Microsoft."},{"Name":"visual-studio","Synonyms":"visualstudio","Count":25157,"Excerpt":"Visual Studio is an integrated development environment (IDE) from Microsoft. It supports many different programming languages."},{"Name":"visual-studio-2008","Synonyms":"visualstudio2008","Count":13539,"Excerpt":"This tag refers to the Visual Studio line of software development products from Microsoft, the 2008 version."},{"Name":"visual-c++","Synonyms":"visualc++","Count":12298,"Excerpt":"Microsoft Visual C++ is a C and C++ compiler for Windows. The most recent version of the compiler is Visual C++ 2012, which is available in both commercial editions and in a free Express Edition.\r\n\r\nThe compiler supports the following languages:\r\n\r\n\r\nC: Only the C90 standard is supported; there is very limited C99 support\r\nC++: Also includes support for several major C++11 features as of Visual Studio 2010\r\nC++/CLI and .NET Managed Extensions for C++"},{"Name":"vba","Synonyms":"visual-basic-applications","Count":12195,"Excerpt":"Visual Basic for Applications (VBA) is an event-driven programming language which was first introduced by Microsoft in 1993 to give Excel 5.0 a more robust object-oriented language for writing macros and automating the use of Excel.  It is now used for the entire Office suite. If your question is specifically about programming Excel, Access, Word or Outlook, use the appropriate tag: excel-vba, access-vba, word-vba or outlook-vba."}]

它们似乎也有点滞后,因此它们不会同时发出太多 HTTP 请求。在它执行请求之前,您必须停止输入一两秒钟。

关于javascript - SO是如何动态获取它的Tag的呢?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14594025/

相关文章:

javascript - 从弹出窗口在父窗口中提交表单?

javascript - 如果所有复选框都被选中,则执行此操作,否则执行此操作(jQuery)

javascript - 世博会: "auth/operation-not-supported-in-this-enviroment"

php - 在 ajax 调用中 Laravel 4 资源中的更新函数使用什么 url

javascript - Ui-router加载状态,那我怎么运行一个函数呢?

Javascript调用php函数并接收返回结果

javascript - 如何使用ajax jquery获取表单字段值并将其作为json发送到服务器

php - 如何使用 Javascript ajax 发送 url?

另一个页面上的 JavaScript Session 存储变量

javascript - 为什么我得到 process.stdin undefined