二次开发问题-在LIB_INSERT.PHP中加参数程序不正常运行的问题
2016-07-07 15:04 来源:www.chinab4c.com 作者:ecshop专家
请行家指教,问题说明如下: ----------------------------------- 加参数前,程序正常运行: 原来lib_insert.php的插入历史函数没有加入参数, function insert_history()//lib_insert.php { $str = ''; if (!empty($_COOKIE['ECS']['history'])) { $where = db_create_in($_COOKIE['ECS']['history'], 'goods_id'); $sql= 'SELECT goods_id, goods_name, goods_thumb, shop_price FROM ' . $GLOBALS['ecs']->table('goods') . " WHERE $where AND is_on_sale = 1 AND is_alone_sale = 1 AND is_delete = 0"; $query = $GLOBALS['db']->query($sql); $res = array(); while ($row = $GLOBALS['db']->fetch_array($query)) { $goods['goods_id'] = $row['goods_id']; $goods['goods_name'] = $row['goods_name']; $goods['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; $goods['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); $goods['shop_price'] = price_format($row['shop_price']); $goods['url'] = build_uri('goods', array('gid'=>$row['goods_id']), $row['goods_name']); $str.=' <ul class="clearfix"> <li class="goodsimg"> <a href="'.$goods['url'].'" target="_blank"> <img src="'.$goods['goods_thumb'].'" alt="'.$goods['goods_name'].'" class="B_blue" /> </a> </li> <li> <a href="'.$goods['url'].'" target="_blank" title="'.$goods['goods_name'].'">'.$goods['short_name'].' </a> <br />'.$GLOBALS['_LANG']['shop_price'].' <font class="f1">'.$goods['shop_price'].' </font> <br /> </li> </ul>'; } $str .= ' <ul id="clear_history"> <a>' . $GLOBALS['_LANG']['clear_history'] . ' </a> </ul>'; } return $str; } 在common.js中的addToCart函数可以通过ajax.call到flow.php function addToCart(goodsId, parentId) { var goods= new Object(); var spec_arr = new Array(); var fittings_arr = new Array(); var number= 1; var formBuy= document.forms['ECS_FORMBUY']; // 检查是否有商品规格 if (formBuy) { spec_arr = getSelectedAttributes(formBuy); if (formBuy.elements['number']) { number = formBuy.elements['number'].value; } } goods.spec = spec_arr; goods.goods_id = goodsId; goods.number= number; goods.parent= (typeof(parentId) == "undefined") ? 0 : parseInt(parentId); Ajax.call('flow.php?step=add_to_cart', 'goods=' + goods.toJSONString(), addToCartResponse, 'POST', 'JSON'); } 但是在lib_insert.php中加入参数之后 function insert_history($arr) { $str = ''; if (!empty($_COOKIE['ECS']['history'])) { $where = db_create_in($_COOKIE['ECS']['history'], 'goods_id'); $sql= 'SELECT goods_id, goods_name, goods_thumb, shop_price FROM ' . $GLOBALS['ecs']->table('goods') . " WHERE $where AND is_on_sale = 1 AND is_alone_sale = 1 AND is_delete = 0"; $query = $GLOBALS['db']->query($sql); $res = array(); while ($row = $GLOBALS['db']->fetch_array($query)) { //print_r ($GLOBALS['db']->fetch_array($query)); $goods['goods_id'] = $row['goods_id']; $goods['goods_name'] = $row['goods_name']; $goods['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; $goods['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); $goods['shop_price'] = price_format($row['shop_price']); $goods['url'] = build_uri('goods', array('gid'=>$row['goods_id'], 'aaa'=>$arr['aaa'], 'bbb'=>$arr['bbb'], 'ccc'=>$arr['ccc']), $row['goods_name']);//'aaa'=>$arr['aaa'], 'bbb'=>$arr['bbb'], 'ccc'=>$arr['ccc']是新加入的参数 $str.=' <ul class="clearfix"> <li class="goodsimg"> <a href="'.$goods['url'].'" target="_blank"> <img src="'.$goods['goods_thumb'].'" alt="'.$goods['goods_name'].'" class="B_blue" /> </a> </li> <li> <a href="'.$goods['url'].'" target="_blank" title="'.$goods['goods_name'].'">'.$goods['short_name'].' </a> <br />'.$GLOBALS['_LANG']['shop_price'].' <font class="f1">'.$goods['shop_price'].' </font> <br /> </li> </ul>'; } $str .= ' <ul id="clear_history"> <a>' . $GLOBALS['_LANG']['clear_history'] . ' </a> </ul>'; } return $str; } 加入的参数是$arr,从模版中获得的参数是'aaa'=>$arr['aaa'], 'bbb'=>$arr['bbb'], 'ccc'=>$arr['ccc'], 加了参数以后,出现问题: --------------------------------------------------------------------------- 在加入参数之后,addToCart在Ajax.call后无法跳转的flow.php 错误在: case "JSON" : result = this.preFilter(xhr.responseText); try { result = result.parseJSON(); } catch (ex) { throw this.filename + "/parseResult() error: can't parse to JSON.\n\n" + xhr.responseText;//程序运行到这里无法继续运行 } break; 在insert_history中不加参数addToCart就可以跳转到flow.php,但是加入参数之后就无法跳转到flow.php |
回答:
在模板里是{insert name=‘history'aaa=$aaa bbb=$bbb}是这样调用的吗?最好能alert出返回的ajax里报什么错了 |
最近更新
常用插件
- ecshop2.7.1打印发货单插件
ecshop2.7.1打印发货单插件介绍:ecshop2.7.1和以前的ecshop版本不一样,ecs...
- ecshop分类批量扩展插件
ecshop分类批量扩展插件,这个插件是ecshop插件里面比较核心的插件。我们...
- ecshop二次开发详细页面生
插件介绍: ECSHOP系统,在很多时候,很多商品没有人购买,不但购买的人...
- ecshop二次商品订购人信息
ecshop二次商品订购人信息填写插件,有时候给朋友送花,或者是送礼品的...
- ecshop商品分类名称增加样
ecshop插件介绍:本插件可以方便在后台管理,为ecshop商品分类名称增加样...
ecshop热门问答
ecshop热门资料
ecshop邮件群发
ecshop多语言
ecshop炮火支援
ecshopput
ecshop迅捷订单打印发货软件
ecshop久钰久商城技术共享
golang
ecshopECMALL第三方登陆
返利网cps
ecshop订单查询
ecshop操作性
ecshop首页模板
ecshopfollowing
ecshop百度快照
ecshop分类问题
ecshop追踪
ecshop大图预览
ecshop惨痛
ecshop打折信息
ecshop实物
ecshoplibs
ecshop全站
ecshop辽宁
ecshop列印
ecshop抓取图片
ecshop图片被拉长
ecshop导出数据
ecshopgoodbaby导航
ecshop引擎
ecshop摆设