加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

has no method 'ajax'

发布时间:2020-12-16 00:38:12 所属栏目:百科 来源:网络整理
导读:今天弄好久。直接拿例子吧。 function addWatchItem(param1,param2){ $.ajax({ url : 'addWatchItem.html', data : {auctionItemId: param1,flag:param2}, success : function(data){ if(data=="error"){ alert("内部错误!"); return false; } } }); } 按照

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

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;
}

}
});
}

神奇的好了。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读