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----------");
    }

  • 相关阅读:
    curl post
    mysql存储引擎
    梳理版本控制器:SVN和Git比较
    详细说明php的4中开源框架(TP,CI,Laravel,Yii)
    五种常见的 PHP 设计模式
    php+ajax实现跨域单点登录
    laravel
    Gitlab配置webhooks实现自动化部署
    linux CentOs7 安装gitlab
    身份证验证
  • 原文地址:https://www.cnblogs.com/myibm/p/5992095.html
Copyright © 2011-2022 走看看