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',
data : {auctionItemId: param1, flag:param2},
success : function(data){
if(data=="error"){
alert("内部错误!");
return false;
}

}
});
}

神奇的好了。


这个错误提示表明在一个'str'对象上调用了一个不存在的方法'method'。这通常是由于你试图在一个字符串上调用一个方法,但这个方法并不存在于字符串对象中。可能的原因是你在处理字符串时,错误地尝试调用了一个不存在于字符串对象中的方法。 要解决这个问题,你需要确定你在字符串对象上尝试调用的方法是否正确,并确保该方法存在于字符串对象的方法列表中。另外,你还需要检查方法的拼写是否正确,并确保你正确地使用了方法的参数。 如果你需要在字符串和字节之间进行转换,你可以使用字符串的`encode()`方法将字符串编码为指定的字节,或使用字节的`decode()`方法将字节解码为字符串。请确保在使用这些方法时,你传递了正确的参数,以便正确地进行编码和解码操作。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [已解决AttributeError: ‘str‘ object has no attribute ‘decode‘方案一](https://blog.csdn.net/weixin_50843918/article/details/129931638)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* [AttributeError: ‘str‘ object has no attribute ‘prefix_chars‘——类实例化不带括号的后果](https://blog.csdn.net/tushuguan_sun/article/details/108964297)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值