今天弄好久。直接拿例子吧。
function addWatchItem(param1,param2){
$.ajax({
url : 'addWatchItem.html',
data : {auctionItemId: param1, flag:param2},
success : function(data){
if(data=="error"){
alert("内部错误!");
return false;
}
}
});
}
按照我们的写法习惯。我写成了$.ajax 但是一直报错。。包的错误为has no method 'ajax'
Uncaught TypeError: Object #<Object> has no method 'ajax'
后来在google上查找
Looking at the definition of $ in your code, it seems like you're using the Prototype framework as well. A problem when using multiple libraries is that they are overwriting variables, mainly the $.
In your case, use jQuery instead of $ (so jQuery.ajax(...)), or use jQuery.noConflict to restore the $ back to the jQuery one.
即:
function addWatchItem(param1,param2){
jquery.ajax({
url : 'addWatchItem.html',
data : {auctionItemId: param1, flag:param2},
success : function(data){
if(data=="error"){
alert("内部错误!");
return false;
}
}
});
}
神奇的好了。
本文介绍了一种在同时使用jQuery和Prototype框架时遇到的问题及解决方案。主要问题是由于这两个框架都使用了$符号作为主要调用方式,导致了冲突。文章提供了通过jQuery.noConflict()方法或者直接使用jQuery替代$符号来解决此问题的方法。
1823

被折叠的 条评论
为什么被折叠?



