| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2851 人关注过本帖
标题:AJAX调用REST API返回NULL
只看楼主 加入收藏
janba
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2016-1-30
收藏
 问题点数:0 回复次数:0 
AJAX调用REST API返回NULL
各位大侠,小弟最近遇到一个难题,请各位不吝帮忙,先谢过,问题如下:

我可以通过IE8浏览器调用以下API
# Request
GET https://www.
# Response
{
    "date": "1410431279",
    "ticker": {
        "buy": "33.15",
        "high": "34.15",
        "last": "33.15",
        "low": "32.05",
        "sell": "33.16",
        "vol": "10532696.39199642"
    }
}
这个API还有以下的说明:All requests go over https protocol, The field 'contentType' in request header should be: 'application/x-www-form-urlencoded'. The root url is: https://www.

然后我在JS中想通过AJAX调用,缺发现跳出的信息窗是"用户名:null",源代码如下:
 <script src="Js/jquery-1.4.2.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $("#btnSave").click(
               function () {
                $.ajax({
                    type: "get",
                    contentType: "application/x-www-form-urlencoded",
                    dataType: "json",
                    url: "https://www.,
                    success: function (data) {
                        alert("用户名:" + data);
                    },
                    error: function (error) {
                        alert("出错:" + error.responseText);
                    }
                });
            }
            );

        })
    </script>
搜索更多相关主题的帖子: 浏览器 request Request protocol field 
2016-01-30 22:32
快速回复:AJAX调用REST API返回NULL
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.026230 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved