<small id='4N5SM'></small><noframes id='4N5SM'>

      • <bdo id='4N5SM'></bdo><ul id='4N5SM'></ul>

    1. <legend id='4N5SM'><style id='4N5SM'><dir id='4N5SM'><q id='4N5SM'></q></dir></style></legend>

    2. <i id='4N5SM'><tr id='4N5SM'><dt id='4N5SM'><q id='4N5SM'><span id='4N5SM'><b id='4N5SM'><form id='4N5SM'><ins id='4N5SM'></ins><ul id='4N5SM'></ul><sub id='4N5SM'></sub></form><legend id='4N5SM'></legend><bdo id='4N5SM'><pre id='4N5SM'><center id='4N5SM'></center></pre></bdo></b><th id='4N5SM'></th></span></q></dt></tr></i><div id='4N5SM'><tfoot id='4N5SM'></tfoot><dl id='4N5SM'><fieldset id='4N5SM'></fieldset></dl></div>
    3. <tfoot id='4N5SM'></tfoot>
    4. 在经典 ASP 页面中编写 JSON,以及对 Http 响应的一

      时间:2023-10-12

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

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

          1. <tfoot id='YCV6t'></tfoot>

                本文介绍了在经典 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 响应的一般(错误)理解的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:将阿拉伯文本转换为 HTML 代码字符 下一篇:JavaScript/jQuery:如何在用户离开页面之前确保跨域

                相关文章

                最新文章

              • <small id='htSdu'></small><noframes id='htSdu'>

                <tfoot id='htSdu'></tfoot>
                  <bdo id='htSdu'></bdo><ul id='htSdu'></ul>

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