Ajax Jquery的疑惑 [英] Ajax Jquery doubts
问题描述
为什么我们必须将 jquery.mn.js (某些文件)添加到SCRIPT标签..,以及表单验证和其他一些jquery和ajax程序。
我们可以在哪里下载该文件,以及在PC中保存该文件的位置。
解决方案如果没有在您的页面上引用库(通常位于< head>
标签)中,jQuery代码将无法正常工作。 另外,还有一些其他的库,它们构建在jQuery库之上,比如Twitter的优秀的 getbootstrap.com/getting-started/rel =nofollow>引导程序库或 jQueryUI 。在这些情况下,您需要 jQuery库和附加库 - 如下面第一个示例中针对jQueryUI所示。
在页面中包含jQuery库有几个选项。
CDN(内容分发网络)是在线存储位置,网页可以抓取指定的代码,而不需要将其存储在服务器上。 这就是为什么CDN是好的想法。
一:1.使用CDN:
< HEAD>
< script src =// ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js\"> ;</script>
< script src =// ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js\"> ;</script>
< link rel =stylesheethref =http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css/>
< / head>
二:2.下载jQuery脚本:
- 去这里: http://jquery.com/download/
- 点击您想要的版本
- 当您在浏览器中看到代码时,将其保存到文本文件中
- 将jquery.js文件存储在webroot(通常是
public_html
)中是最简单的,但您可以将其存储在任何地方(并将其命名为任何您想要的内容 - 当您在< script>
标记中引用它时,您只需使用相同的名称/位置。 - 存储在一个名为
js
的子目录中。 -
将其包含在头标记中,即:
三:3.上述组合,后备
< script src =// ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js type =text / javascript>< / script>
& LT;脚本> window.jQuery || document.write('< script src =../ js / jquery-1.10.2.min.js>< \ / script>')< / script>
上面的代码是这样的:
一个。从CDN中加载jQuery库
b。如果CDN没有加载,请从指定位置加载jQuery服务器(请注意,jQuery库也必须位于您的服务器上,位于指定位置)。
注意: b Why we have to add jquery.mn.js (some file ) to the SCRIPT tag.., in form validation and some other jquery and ajax programs.. Where we can download that file., and where have to SAVE that file in PC. jQuery code will not work without the library being referenced on your page (usually in the Also, there are some other libraries that build on top of the jQuery library, like Twitter's excellent bootstrap library, or jQueryUI. In those cases, you need both the jQuery library and the additional library -- as shown for jQueryUI in the first example below. There are a few options for including jQuery libraries on your page. CDNs (Content Delivery Networks) are online storage locations where web pages can grab the specified code, without you needing to store it on your server. This is why a CDN is a good idea. One: 1. Use a CDN: Two: 2. Download the jQuery script: Include it in your head tags, thus: Three: 3. A combination of the above, with fallback The above code does this: a. Load the jQuery library from the CDN Notes: 这篇关于Ajax Jquery的疑惑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
$ b
<head>
tags). <head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" />
</head>
public_html
), but you can store it anywhere (and name it anything you want -- you just have to use the same name/location when you reference it in your <script>
tag.js
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"></script>
<script> window.jQuery || document.write('<script src="../js/jquery-1.10.2.min.js"><\/script>')</script>
b. IF the CDN did not load, then load the jQuery from the specified location on my server (Note that the jQuery library must also be available on your server, at the location specified).