JQuery:$ .get不是一个函数 [英] JQuery: $.get is not a function
问题描述
我在jQuery中做一些非常基本的问题。有人可以告诉我我到底做错了什么吗?
I'm having a problem doing something very basic in jQuery. Can someone tell me what I'm doing wrong exactly?
如果我运行下面的代码,函数$ .get似乎丢失了(getJSON和其他人也丢失了) 。但是$本身和其他函数确实存在,所以我知道JQuery正在加载。
If I run the code below, the function $.get seems to be missing (getJSON and others missing too). But $ itself and other functions do exist, so I know JQuery is loading.
google.load("jquery", "1.3.2");
function _validate(form, rules_file) {
$.get('/validation_rules.json',function(data) {
alert("hello")
})
}
任何想法都会非常感激。
Any ideas would be much appreciated.
谢谢,
Rob
Thanks, Rob
编辑:这里有一些额外的信息:
here is some additional info:
<script src="http://www.google.com/jsapi"></script>
<script>
google.load("prototype", "1.6");
google.load("scriptaculous", "1.8");
google.load("jquery", "1.3.2");
</script>
<script>
jQuery.noConflict(); // prevent conflicts with prototype
</script>
<script src="/livepipe/src/livepipe.js"
type="text/javascript"></script>
<script src="/livepipe/src/window.js"
type="text/javascript"></script>
<script src="/livepipe/src/tabs.js"
type="text/javascript"></script>
<script src="/jquery.maskedinput-1.2.2.js"
type="text/javascript"></script>
推荐答案
$
变量来自Prototype-js,因为您使用的是 jQuery.noConflict
方法。
The $
variable you have is from Prototype-js, because you are using the jQuery.noConflict
method.
该方法将恢复 $
变量回到第一个实现它的库。
That method will restore the $
variable back to whichever library first implemented it.
你应该直接在 jQuery
全局对象上使用jQuery方法,例如:
You should use the jQuery methods on the jQuery
global object directly, eg.:
jQuery.get(/* .. */);
jQuery.getJSON(/* .. */);
// etc...
或者你可以定义另一个较短的变量作为别名想要:
Or you can define another shorter variable as alias if you want:
var $j = jQuery.noConflict();
这篇关于JQuery:$ .get不是一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!