<i id='xtTrZ'><tr id='xtTrZ'><dt id='xtTrZ'><q id='xtTrZ'><span id='xtTrZ'><b id='xtTrZ'><form id='xtTrZ'><ins id='xtTrZ'></ins><ul id='xtTrZ'></ul><sub id='xtTrZ'></sub></form><legend id='xtTrZ'></legend><bdo id='xtTrZ'><pre id='xtTrZ'><center id='xtTrZ'></center></pre></bdo></b><th id='xtTrZ'></th></span></q></dt></tr></i><div id='xtTrZ'><tfoot id='xtTrZ'></tfoot><dl id='xtTrZ'><fieldset id='xtTrZ'></fieldset></dl></div>
  1. <small id='xtTrZ'></small><noframes id='xtTrZ'>

      • <bdo id='xtTrZ'></bdo><ul id='xtTrZ'></ul>
    1. <legend id='xtTrZ'><style id='xtTrZ'><dir id='xtTrZ'><q id='xtTrZ'></q></dir></style></legend>

      <tfoot id='xtTrZ'></tfoot>
    2. 在经典 ASP 页面中编写 JSON,以及对 Http 响应的一般(错误)理解

      Writing JSON in Classic ASP page, and general (mis)understanding of Http Response(在经典 ASP 页面中编写 JSON,以及对 Http 响应的一般(错误)理解)
    3. <i id='8kcAR'><tr id='8kcAR'><dt id='8kcAR'><q id='8kcAR'><span id='8kcAR'><b id='8kcAR'><form id='8kcAR'><ins id='8kcAR'></ins><ul id='8kcAR'></ul><sub id='8kcAR'></sub></form><legend id='8kcAR'></legend><bdo id='8kcAR'><pre id='8kcAR'><center id='8kcAR'></center></pre></bdo></b><th id='8kcAR'></th></span></q></dt></tr></i><div id='8kcAR'><tfoot id='8kcAR'></tfoot><dl id='8kcAR'><fieldset id='8kcAR'></fieldset></dl></div>

    4. <legend id='8kcAR'><style id='8kcAR'><dir id='8kcAR'><q id='8kcAR'></q></dir></style></legend>

      <small id='8kcAR'></small><noframes id='8kcAR'>

        • <bdo id='8kcAR'></bdo><ul id='8kcAR'></ul>
          <tfoot id='8kcAR'></tfoot>
            <tbody id='8kcAR'></tbody>

                本文介绍了在经典 ASP 页面中编写 JSON,以及对 Http 响应的一般(错误)理解的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有一个经典的 ASP 页面 (VBscript),它在服务器端生成一个 XML,然后 Response.Writes 它.该页面根本没有客户端.

                I had a classic ASP page (VBscript) that generates an XML on server-side, and then Response.Writes it. The page had no client side at all.

                但是我需要将其转换为 JSON.由于我找不到有效的 ASP 服务器端方式(完全不同的主题),所以我在客户端使用我找到的 Javascript 代码完成了它,最后将它记录到页面中.

                However I needed to convert it to JSON. Since I could not find an ASP server-side way that worked (whole different subject) I did it on client-side with a Javascript code I found, finally document.writing it to the page.

                问题是结果不一样:如果在 http RESPONSE 之前只是一个 XML,那么现在的响应是 javascript 代码,它将 JSON 写入浏览器,而不是响应.我理解对了吗?

                THE PROBLEM is that the result is not the same: If before the http RESPONSE was only an XML, the response now is the javascript code, which writes to the browser the JSON , but not to the response. Am I understanding this right?

                换句话说,如果之前我有一个 xml 作为响应,那么现在的响应是这样的:

                In other words, if before I had an xml as the response, now the response is this:

                    <script type="text/javascript">     
                        var xmlObj = parseXml('<%=resultXml%>');    
                        var json = xml2json(xmlObj);    
                        document.write(json);
                    </script>   
                

                整个块由 ASP 在这样的方法中调用:

                This whole block is called by the ASP inside a method like this:

                sub writeJsonResult(resultXml) 
                % > 
                
                        the above javascript is here
                
                < %     end sub
                % >
                

                同样,浏览器明显显示 JSON,但使用它的服务没有获得所需的响应.有没有办法将 JSON 写为响应?我觉得我遗漏了一些东西并且不太理解这一点.

                So again, visibly the browser shows the JSON, but the service that uses it doesn't get the RESPONSE it needs. Is there a way to write the JSON as response? I feel I am missing something and not quite understanding this.

                推荐答案

                AS @Quentin 有 指出;

                服务期望获取 JSON.

                这意味着试图通过处理 JSON 客户端来解决这个问题是行不通的,因为这意味着您已经发回了 text/html HTTP 响应而不是 application/json 一.无法绕过它,您必须处理 XML 以在服务器端构建 JSON 结构,然后使用返回它

                This means trying to get around that by processing the JSON client-side isn't going to work as that would mean you have sent back a text/html HTTP response instead of a application/json one. There is no getting around it you have to process the XML to build a JSON structure server-side then return it using

                Response.ContentType = "application/json"
                

                有很多适用于 Classic ASP 的 JSON 库,有的很好,有的很棒,有的简直太糟糕了.如果您正在寻找推荐 ASPJSON.com 可能是使用最广泛的库(但奇怪的是,该网站目前似乎已关闭).

                There are lots of JSON libraries out there for Classic ASP, some good, some great and some just plain awful. You just need to have a look through and see which one suits you, if you are looking for a recommendation ASPJSON.com is probably the most widely used library (but weirdly the site appears to be down at the moment).

                如果可能的话,在生成 XML 的地方使用上述库将其替换为 JSON,它们中的大多数都支持直接从数据库构建 JSON 结构,从而节省您自己从 XML 解析和构建 JSON 的时间.

                If possible where the XML is generated replace this with a JSON using a library like described above, most of them support building JSON structures directly from the database, saving you on parsing and building the JSON from the XML yourself.

                • 在经典 ASP 中解析 JSON 有什么好的库吗?[关闭]

                经典 ASP JSON 类 (站点当前关闭)

                RCDMK 的 JSON 对象类 3.4.1

                这篇关于在经典 ASP 页面中编写 JSON,以及对 Http 响应的一般(错误)理解的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                What are valid deviceNames for Chrome emulation testing with Protractor?(使用 Protractor 进行 Chrome 模拟测试的有效设备名称是什么?)
                Protractor Check if Element Does Not Exist(量角器检查元素是否不存在)
                Protractor e2e Tests Login Redirection(Protractor e2e 测试登录重定向)
                Explain about async/ await in Protractor(解释 Protractor 中的 async/await)
                Protractor browser.wait doesn#39;t wait(量角器 browser.wait 不等待)
                How to use Protractor with Angular 2?(如何在 Angular 2 中使用量角器?)

                1. <tfoot id='lA7qt'></tfoot>
                    <tbody id='lA7qt'></tbody>

                  <small id='lA7qt'></small><noframes id='lA7qt'>

                2. <legend id='lA7qt'><style id='lA7qt'><dir id='lA7qt'><q id='lA7qt'></q></dir></style></legend>
                    <bdo id='lA7qt'></bdo><ul id='lA7qt'></ul>
                    <i id='lA7qt'><tr id='lA7qt'><dt id='lA7qt'><q id='lA7qt'><span id='lA7qt'><b id='lA7qt'><form id='lA7qt'><ins id='lA7qt'></ins><ul id='lA7qt'></ul><sub id='lA7qt'></sub></form><legend id='lA7qt'></legend><bdo id='lA7qt'><pre id='lA7qt'><center id='lA7qt'></center></pre></bdo></b><th id='lA7qt'></th></span></q></dt></tr></i><div id='lA7qt'><tfoot id='lA7qt'></tfoot><dl id='lA7qt'><fieldset id='lA7qt'></fieldset></dl></div>