• 都说了是随笔了还要什么标题


    <script type="text/javascript">
    $(function () {
    $("#btnOK").click(function () {
    $.ajax({
    type: "POST",
    url: "/Storage/CreateGeotable",
    data: { name: "位置数据表", geotype: 1, is_published: 1, ak: "DqsjAlqpyHfX2igOzIxCeFwU" },
    datatype: "json",
    success: function (data) {
    alert(data.length);
    },
    error: function () {
    alert("error");
    }
    });
    });
    //
    $("#btnGet").click(function () {
    $.ajax({
    type: "POST",
    url: "/Storage/HttpGet",
    data: { url: "http://api.map.baidu.com/geodata/v3/geotable/list", ak: "DqsjAlqpyHfX2igOzIxCeFwU" },
    datatype: "json",
    success: function (data) {
    alert(data.length);
    },
    error: function () {
    alert("error");
    }
    });
    });
    });
    </script>

    public JsonResult HttpPost(string name, int geotype, int is_published, string ak)
    {
    string url = "http://api.map.baidu.com/geodata/v3/geotable/create";
    string postData = "name=" + name + "&geotype=" + geotype + "&is_published=" + is_published + "&ak=" + ak + ""; //
    byte[] byteArray = Encoding.UTF8.GetBytes(postData);

    HttpWebRequest objWebRequest = (HttpWebRequest)WebRequest.Create(url);
    objWebRequest.Method = "POST";
    objWebRequest.ContentType = "application/x-www-form-urlencoded";
    objWebRequest.ContentLength = byteArray.Length;
    Stream newStream = objWebRequest.GetRequestStream();
    newStream.Write(byteArray, 0, byteArray.Length);
    newStream.Close();

    HttpWebResponse response = (HttpWebResponse)objWebRequest.GetResponse();
    StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.Default);
    string textResponse = sr.ReadToEnd(); // 返回的数据
    return Json(url);
    }

    public string HttpGet(string url, string ak)
    {
    string getUrl = url + "?ak=" + ak;
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(getUrl);
    request.Method = "GET";
    request.ContentType = "text/html;charset=UTF-8";

    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    Stream myResponseStream = response.GetResponseStream();
    StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));
    string retString = myStreamReader.ReadToEnd();
    myStreamReader.Close();
    myResponseStream.Close();

    return retString;
    }

  • 相关阅读:
    缓冲式I/O
    事件轮询接口
    博弈游戏
    多任务I/O之poll函数
    好的link
    做纹理处理的。。。
    快毕业了!
    语音处理的资料
    google图像搜索原理
    install opencv in centos
  • 原文地址:https://www.cnblogs.com/niejun/p/4616384.html
Copyright © 2020-2023  润新知