zoukankan      html  css  js  c++  java
  • Flex HTTPService json

    import mx.rpc.events.FaultEvent;
    import mx.rpc.events.ResultEvent;
    import mx.rpc.http.HTTPService;
    import mx.controls.Alert;
    import com.adobe.serialization.json.JSON;

    private var httpService:HTTPService = new HTTPService();
    protected function button1_clickHandler(event:MouseEvent):void
    {


    httpService.url="http://localhost:8080/trf/xt/traffic";
    httpService.method="POST";                         //重要,默认GET
    httpService.contentType="application/json";    //重要,默认XML
    httpService.showBusyCursor = true;
    httpService.addEventListener(ResultEvent.RESULT,getResult);
    httpService.addEventListener(FaultEvent.FAULT,getFailure);

    var sub:Object= new Object();
    sub.id=1;
    var para:Object =new Object();
    para.cmd="findXhjById";
    para.token="token";
    para.params= sub;
    var jstr:Object=com.adobe.serialization.json.JSON.encode(para); //重要
    httpService.send(jstr);

    }

    private function getResult(event:ResultEvent){


    Alert.show("-----------success----------");
    var obj:Object= com.adobe.serialization.json.JSON.decode(event.message.body.toString());
    Alert.show("address:" + obj.detail.address);


    }

    private function getFailure(event:FaultEvent){
         Alert.show("-----------Failure----------");
    }

  • 相关阅读:
    js 与或运算符 || && 妙用(great!!!)
    type of && undefined
    全新框架?微信小程序与React Native的异同之处
    JS-十五章(15.16)
    JS-第十三章
    ValueError: zero-size array to reduction operation maximum which has no identity
    time
    模块
    day8-函数
    day7-format字符串格式化
  • 原文地址:https://www.cnblogs.com/myibm/p/5992095.html
Copyright © 2011-2022 走看看