ecshop中ajax.call使用

ajax.call封装在js目录下transport.js这个文件.里面

<script type=”text/javascript”>// <![CDATA[
function colour_label(val,id)
{
   Ajax.call(“goods.php?act=img_label”, “label=” val “&#038;&id=” id, addresscolour_label , “POST”, “JSON”,false);
}

ajax.call后面的参数分别是(请求的URL地址,发送参数,回调函数,请求的方式,有”GET”和”POST”两种,响应类型,有”JSON”、”XML”和”TEXT”三种,是否异步请求的方式,是否安静模式请求)

function addresscolour_label(result)
{
    if(result == “true”)
    {

        alert(result.label);
        for (var one in result.colour_label)
        {
             laert(result.colour_label[one].img_id);
        }
    }
}

的result参数就是goods.php?act=img_label这里输出响应结果.下面是结果

{
“label”:”\u9ed1\u8272″,
“colour_label”:
  [
    {
       “img_id”        : “1012”,
       “img_url”       : “images\/201309\/goods_img\/439_P_1380475365329.jpg”,
       “thumb_url”     : “images\/201309\/thumb_img\/439_thumb_P_1380475365276.jpg”,
       “img_desc”      : “\u68d5\u8272”,
       “goods_id”      : “439”,
       “goods_attr_id” : “2435”
     },
     {
       “img_id”        : “1006”,
       “img_url”       : “images\/201309\/goods_img\/439_P_1380475364611.jpg”,
       “thumb_url”     : “images\/201309\/thumb_img\/439_thumb_P_1380475364120.jpg”,
       “img_desc”      : “\u767d\u8272”,
       “goods_id”      : “439”,
       “goods_attr_id” : “2457”
     },
     {
       “img_id”        : “1009”,
       “img_url”       : “images\/201309\/goods_img\/439_P_1380475365389.jpg”,
       “thumb_url”     : “images\/201309\/thumb_img\/439_thumb_P_1380475365508.jpg”,
       “img_desc”      : “\u9ed1\u8272”,
       “goods_id”      : “439”,
       “goods_attr_id” : “2434”
     }
  ],
“attr_price”:12
}
<script>

php 文件
if($_REQUEST[“act”] == “img_label”)
{
    include_once(“includes/cls_json.php”);
    $json      =   new JSON;

    $label     =   $_REQUEST[“label”];
    $goods_id  =   $_REQUEST[“id”];

    $result[“label”] = $label;
    $sql = “SELECT a.img_id, a.img_url, a.thumb_url, a.img_desc, a.goods_id, b.goods_attr_id” .
           ” FROM ” . $GLOBALS[“ecs”]->table(“goods_gallery”) .” as a “.
    ” left join  “. $GLOBALS[“ecs”]->table(“goods_attr”) .” as b on(a.goods_id = b.goods_id and a.img_desc= b.attr_value ) “.
           ” WHERE a.goods_id = “$goods_id” and a.img_label = “1” group by a.img_desc asc “;
    $result[“colour_label”] = $GLOBALS[“db”]->getAll($sql);

    die($json->encode($result));
}
// ]]></script>