自己写个ajax请求的php页面test.php:
define('IN_ECS', true);
require(dirname(__FILE__) . '/includes/init.php');
$sql = "select goods_number from ". $GLOBALS['ecs']->table('cart') . ' where user_id = '. $_SESSION["user_id"];
$number = $GLOBALS['db']->getOne($sql);
echo $number;
调用ecshop封装的ajax方法Ajax.call:
Ajax.call('test.php','',myresponse,'POST','TEXT');ajax请求test.php 得到结果result,通过回调函数赋值给id为id的元素。
function myresponse(result){
var text = document.getElementbyId('id');
text.val = result;
}