开发者

Can I include jQuery and AJAX in the same file? Would this conflict?

Can I include jQuery and AJAX in the sa开发者_开发技巧me file? Would this conflict?

I am attempting to include jQuery with a Magento GO template, but when I upload and include jQuery in the template, the drop down menus/etc. stop working. The links all still work fine, but the dropdown menus, and other similar functionality stop working...

I believe this may be because Magento includes AJAX in the hosted solution on their end..?


The first line of your jQuery code needs to be:

jQuery.noConflict();

The noConflict function takes out a lot of what causes cross-library errors.


No, using jQuery along with another library that uses AJAX does not cause any conflicts.

What can cause a conflict is that the jQuery library uses the $ identifier. If the other code is also using that, they won't work togehter unless you use the noConflict method in jQuery.


Magento includes Prototype by default. It's strongly recommended that you do NOT add jQuery unless it cannot be avoided. Pretty much any functionality that jQuery provides is also available in Prototype/Scriptaculous, it's just not as popular (and/or well marketed) as jQuery.

As the other answers have suggested, you need to put jQuery into noConflict mode. You will find that you might still encounter other issues, but it's a start.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜