has no method 'ajax'

前端之家收集整理的这篇文章主要介绍了has no method 'ajax'前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

今天弄好久。直接拿例子吧。

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,usejQueryinstead of$(sojQuery.ajax(...)),or usejQuery.noConflictto restore the$back to the jQuery one.

将如上代码 中的$改为 jquery

即:

function addWatchItem(param1,param2){
jquery.ajax({
url : 'addWatchItem.html',
success : function(data){
if(data=="error"){
alert("内部错误!");
return false;
}

}
});
}

神奇的好了。

原文链接:https://www.f2er.com/ajax/165101.html

猜你在找的Ajax相关文章