問題原因:/js/transport.js 文件
Object.prototype.toJSONString = function () {**************}
大概 580行到590行之間 這個句用于格式化json,他重寫了object的結構,導致于js框架沖突,如果要解決需要把這段代碼注釋掉,然后用別的方式替換。
我是將所有用到*.toJSONString的地方,替換成一個函數,例如:
/js/common.js 29行
Ajax.call(‘flow.php?step=add_to_cart', ‘goods=' + goods.toJSONString, addToCartResponse, ‘POST', ‘JSON');
替換成:
Ajax.call(‘flow.php?step=add_to_cart', ‘goods=' + obj2str(goods), addToCartResponse, ‘POST', ‘JSON');
obj2str函數如下:
function obj2str(o){var r = [];if(typeof o ==”string”) return “/”"+o.replace(/([/'/"http://])/g,”//$1″).replace(/(/n)/g,”//n”).replace(/(/r)/g,”//r”).replace(/(/t)/g,”//t”)+”/”";if(typeof o ==”undefined”) return “undefined”;if(typeof o == “object”){if(o===null) return “null”;else if(!o.sort){for(var i in o)r.push(“/”"+i+”/”"+”:”+obj2str(o[i]))r=”{“+r.join()+”}”}else{for(var i =0;i<o.length;i++)r.push(obj2str(o[i]))r=”["+r.join()+"]”}return r;}return o.toString();}
大概這樣就可以了,可能還有些腳步錯誤需要處理,您自己體會下 , 這只是個解決方法,并不一定適用您的網站。
我注釋了下面這一段
/*Object.prototype.toJSONString = function () {……// Join all of the fragments together and return.a.push(‘}');return a.join(”);};*/
新聞熱點
疑難解答