Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/362.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 那么如何动态地获取它的标签呢?_Javascript_Jquery_Ajax_Stack Overflow - Fatal编程技术网

Javascript 那么如何动态地获取它的标签呢?

Javascript 那么如何动态地获取它的标签呢?,javascript,jquery,ajax,stack-overflow,Javascript,Jquery,Ajax,Stack Overflow,当您提问时,stackoverflow如何在下面的标记输入上加载其可用标记?他们是在页面加载时填充可用标记,还是根据用户输入或用户按键发出请求?我计划在我的应用程序中实现同样的方法,但我不知道如何实现这一点。他们肯定不会在页面加载时加载所有可用的标记,因为有太多的标记。我在Firefox的web控制台下运行了一个快速测试,看起来他们使用AJAX执行JSON请求。例如: 结果是: [{"Name":"c#","Synonyms":"visual-c#","Count":409187,"Excer

当您提问时,stackoverflow如何在下面的标记输入上加载其可用标记?他们是在页面加载时填充可用标记,还是根据用户输入或用户按键发出请求?我计划在我的应用程序中实现同样的方法,但我不知道如何实现这一点。

他们肯定不会在页面加载时加载所有可用的标记,因为有太多的标记。我在Firefox的web控制台下运行了一个快速测试,看起来他们使用AJAX执行JSON请求。例如:

结果是:

[{"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请求。在它发出请求之前,您必须停止输入一两秒钟。

如果您想调查安装firebug(针对Firefox)的情况,最好先在web上搜索“javascript ajax autocomplete”或者Similar插件,并在Net tab中分析浏览器请求和服务器响应。加载所有标记是否是一种不好的做法?它会说这可能会影响性能,具体取决于您拥有的标记数量。如果您有20-30个标记,您可以将它们硬编码到浏览器缓存的
.js
文件中。我认为StackOverflow有数千个。但是如果我从数据库本身获取标签呢?如果是我,我会使用类似StackOverflow的方法(使用AJAX动态抓取标签数据)。它更灵活,你不必担心将来会得到太多的标签。尽管如此,你有任何关于我如何做到这一点的参考资料吗?比如从数据库中获取查询结果作为json响应,然后输出?或者某种程度上是相同的实现?