ajax在ecshop上的运用

ajax在 ecshop 上的运用主要分为步骤:

1.编写调用函数:

  function query()
 {
 
    var sn_id = document.getElementById('sn_id').value.replace(/(^\s*)|(\s*$)/g, "");
 if(!have_chinies(sn_id))
      Ajax.call('sn_id.php?sn_id=' + sn_id, '', rep_sn_id, 'GET', 'JSON');
 
 }

 

2.返回前台掉用:

 

<?php   define('IN_ECS', true);

  require(dirname(__FILE__) . '/includes/init.php');   include('includes/cls_json.php');

  $json   = new JSON;   $result = array('goods_name' =>'没有找到任何记录' , 'goods_sn' => '没有找到任何记录');   $sn_id  = !empty($_GET['sn_id'])?$_GET['sn_id']:'';   $sql    = "select goods_name,goods_sn from" . $ecs->table('goods') . "where (goods_id='$sn_id'  or  goods_sn='$sn_id') ";   $res    = $db->getAll($sql);     if(!empty($res))   {     $result['goods_name'] = $res[0]['goods_name'];  $result['goods_sn'] = $res[0]['goods_sn'];     }      die($json->encode($result));

?>

3.执行回调函数:

function rep_sn_id(result) {       document.getElementById('_good_id').innerHTML = '商品名称:' + result.goods_name + "</br>"    document.getElementById('_good_id').innerHTML += '商品编号:' + result.goods_sn + "</br>";

}

 

转载于:https://www.cnblogs.com/shichangyi/archive/2012/12/07/ecshop.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值