API调用返回额外不必要的HTML标头信息

时间:2013-08-23 04:00:40

标签: javascript ajax json api

您好我正在调用API并且正在返回

[{"ActorID":1,"ActorName":"dfdsf","ActorOccupation":0,"ActorLevel":3,"VsRank":10,"PVP_Vs":0,"FightTotalCount":"0","WinCount":"0"},
{"ActorID":2,"ActorName":"sdsf","ActorOccupation":0,"ActorLevel":0,"VsRank":10,"PVP_Vs":0,"FightTotalCount":"0","WinCount":"0"}]


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html 
        xmlns="http://www.w3.org/1999/xhtml">
        <head>
            <title></title>
        </head>
        <body>
            <form method="post" action="GetRankingList.aspx?pvptype=1&amp;sid=1&amp;tm=20130821160000&amp;auth=77c9b582c3aed3d3974400cfb118fe4b" id="form1">
                <div class="aspNetHidden">
                    <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTE2MTY2ODcyMjlkZLSAAAtd4/lj1u6b0GjPWM+p3i9tqI6sq+xDrRw2cAv3" />
                </div>
                <div></div>
            </form>
        </body>
    </html>

我想要的只是简单的JSON数组对象。我没有写这个API,但有人知道我怎么可能只是指定我想要对象本身。我已经指定了

format : "json"
当我拨打这个电话时,

作为参数。无论我如何进行调用(Ajax,浏览器等),都会返回值。

1 个答案:

答案 0 :(得分:0)

另一个(复杂的)解决方案是通过此HTML Sanitizer API运行它 -

https://www.mashape.com/pbkwee/html-sanitizer#!endpoint-HTML-Sanitizer

我在上面运行你的输出,它几乎删除了所有内容,除了它在两端填充div标签(你可以删除它们)