加参数前,程序正常运行:
原来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 onclick="clear_history()">' . $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 onclick="clear_history()">' . $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
原来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 onclick="clear_history()">' . $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 onclick="clear_history()">' . $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
解决方案 »
- 怎么判断一个文件夹中符合判断的所有文件是否全部存在
- IE7,8,Safari下 FORM的多按钮问题
- 如何向CSV文件添加数据,然后添加的数据全部导入到数据库中,请教?如果给出一个例子代码,最好。谢谢。。。。。
- 关于超大文件上传
- 我脑子进水了,超经典低级问题,兄弟们快来啊,关于mysql远程连接问题解决了100分全送!
- 这个问题是怎么回事》???failed to open stream
- 临时写了一个做跳转的程序,能运行,帮我看看有没有漏洞,有没有不合理的地方,谢谢。
- XML+XSL+PHP的问题
- 如何安装php
- 菜鸟求指点:Linux系统上建一个可界面查询的数据库,需要用到哪些技术?
- php文件转化成 html文件问题,在线等
- 求教PHP中str_replace函数问题
{
$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 onclick="clear_history()">' . $GLOBALS['_LANG']['clear_history'] . ' </a> </ul>';
}
return $str;
}