欢迎光临
我们一直在努力

Ecshop与Jquery冲突的解决方案(jquery_json)

ECShop在common/transport.js之中封装了JSON各种方法的同时对object的模型进行了重写,

这个就跟jQuery冲突了。因为众所周知的,jQuery对各种JavaScript对象进行了扩展。

看了网上的方法,自己尝试了下,成功了:

1、首先复制一份 transport.js 改名为 transport.org.js 提供给后台使用,

2、屏蔽掉transport.js里的toJSON功能。

代码行数在497-737行之间。

3、修改相应的文件代码

2.注释掉js/transport.js里的toJSON功能 行数为497-737行之间。其中将

legalParams = “JSON=” + params.toJSONString();替换为legalParams = $.toJSON(params);

result = result.parseJSON();修改为result = $.evalJSON(result);

3.修改js/index.js里的第44行,将

var res = result.parseJSON();改为:var res = $.evalJSON(result);
4.修改js/改common.js,

把Ajax.call(‘flow.php?step=add_to_cart’, ‘goods=’ + goods.toJSONString(), addToCartResponse, ‘POST’, ‘JSON’);
修改为Ajax.call(‘flow.php?step=add_to_cart’, ‘goods=’ + $.toJSON(goods), addToCartResponse, ‘POST’, ‘JSON’);

把Ajax.call(‘flow.php?step=add_package_to_cart’, ‘package_info=’ + package_info.toJSONString(), addPackageToCartResponse, ‘POST’, ‘JSON’);
修改为Ajax.call(‘flow.php?step=add_package_to_cart’, ‘package_info=’ + $.toJSON(package_info), addPackageToCartResponse, ‘POST’, ‘JSON’);

把Ajax.call(‘flow.php?step=add_to_cart’, ‘goods=’ + goods.toJSONString(), addToCartResponse, ‘POST’, ‘JSON’);
修改为Ajax.call(‘flow.php?step=add_to_cart’, ‘goods=’ + $.toJSON(goods), addToCartResponse, ‘POST’, ‘JSON’);

5.修改compare.js文件

this.data = cookieValue.parseJSON();修改为this.data = $.evalJSON(cookieValue);
var obj = cookieValue.parseJSON();修改为var obj = $.evalJSON(cookieValue);
document.setCookie(“compareItems”, this.data.toJSONString());修改为document.setCookie(“compareItems”, $.toJSON(this.data));

6.修改js/global.js文件
function $()修改为function $e()
var element = $(element);修改为var element = $e(element);

7.修改后top.html,menu.html,pageheader.htm 三个文件中:

{insert_scripts files=”../js/transport.org.js,common.js”}

8.修改你的模板下的library/comment_list.lbi。

Ajax.call(‘comment.php’, ‘cmt=’ + cmt.toJSONString(), commentResponse, ‘POST’, ‘JSON’);
修改为Ajax.call(‘comment.php’, ‘cmt=’ + $.toJSON(cmt), commentResponse, ‘POST’, ‘JSON’);

9.修改模板compare.dwt。

把var obj = document.getCookie(“compareItems”).parseJSON();
修改为var obj = $.evalJSON(document.getCookie(“compareItems”));

把document.setCookie(“compareItems”, obj.toJSONString());
修改为document.setCookie(“compareItems”, $.toJSON(obj));

11.修改模板flow.dwt

把Ajax.call(‘flow.php?step=add_to_cart’, ‘goods=’ + goods.toJSONString(), collect_to_flow_response, ‘POST’, ‘JSON’);
修改为Ajax.call(‘flow.php?step=add_to_cart’, ‘goods=’ + $.toJSON(goods), collect_to_flow_response, ‘POST’, ‘JSON’);

把Ajax.call(‘flow.php?step=add_to_cart’, ‘goods=’ + goods.toJSONString(), fittings_to_flow_response, ‘POST’, ‘JSON’);
修改为Ajax.call(‘flow.php?step=add_to_cart’, ‘goods=’ + $.toJSON(goods), fittings_to_flow_response, ‘POST’, ‘JSON’);

 

4、模板中引入文件

{insert_scripts files=’jquery-1.9.1.min.js,jquery.json.js}

jquery.json.js

jquery

赞(0) 打赏
未经允许不得转载:程序开发爱好者 » Ecshop与Jquery冲突的解决方案(jquery_json)
分享到: 更多 (0)

网站设计及开发、微应用及微网站开发、微信公众平台开发、 HTML5手机网站开发、网络整合营销、APP开发、软件开发及企业电商服务

联系我们