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

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

      • <bdo id='kygEc'></bdo><ul id='kygEc'></ul>
      <tfoot id='kygEc'></tfoot>
      1. 跨域 JSON 请求?

        Cross-domain JSON request?(跨域 JSON 请求?)

          <bdo id='hKSCv'></bdo><ul id='hKSCv'></ul>
          • <legend id='hKSCv'><style id='hKSCv'><dir id='hKSCv'><q id='hKSCv'></q></dir></style></legend>
            <tfoot id='hKSCv'></tfoot>

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

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

                  <tbody id='hKSCv'></tbody>
                • 本文介绍了跨域 JSON 请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  问题:

                  我正在尝试跨域使用 JSON,但我发现的只是 JSON 解析器,我不需要...
                  我读过可以使用 JSON 进行跨域请求,但到目前为止,我看到的只是使用 XMLHttpRequest 的实现...
                  - 这意味着您不能使用跨域请求,至少不能在 IE 8 之外使用......
                  我一直在 http://www.json.org/,但我发现的只是解析器还是没用.

                  到目前为止,我在谷歌上找到的最好的是
                  http://devpro.it/JSON/files/JSONRequest-js.html
                  但这相当混乱,不能跨域工作,也不能在域内工作 - 或者根本不工作......

                  I'm trying to use JSON accross domains, but all i find is JSON parsers, which I don't need...
                  I've read that it's possible to do cross-domain requests with JSON, but so far, all I see is implementations that use XMLHttpRequest...
                  - which means you can't use cross-domain requests, at least not outside IE 8...
                  I've been on http://www.json.org/, but all I find is either parsers or useless.

                  The best I've found with google so far is
                  http://devpro.it/JSON/files/JSONRequest-js.html
                  but this is rather a mess, doesn't work cross domain, and intra-domain neither - or rather not at all...

                  var the_object = {}; 
                  var http_request = new XMLHttpRequest();
                  http_request.open( "GET", url, true );
                  http_request.onreadystatechange = function () {
                      if ( http_request.readyState == 4 && http_request.status == 200 ) {
                              the_object = JSON.parse( http_request.responseText );
                          }
                  };
                  http_request.send(null);
                  

                  推荐答案

                  你可以做的跨域注入脚本包括:

                  What you can do cross-domain is inject a script include:

                  var s = document.createElement('script');
                  s.src = 'http://someotherdomain/getMeMyJs.aspx?parameter=value';
                  s.onload = someOptionalCallback;
                  s.type = 'text/javascript';
                  
                  if(document.getElementsByTagName('head').length > 0)
                      document.getElementsByTagName('head')[0].appendChild(s);
                  

                  现在,该请求返回的代码将立即执行.如果您希望它与您的代码交互,您可以确保它与包装在函数调用中的所有数据一起返回:

                  Now, the code returned by that request will be executed immediately. If you want for that to interact with your code, you can make sure that it's being returned with all data wrapped in a function call:

                  jsonCallback({ object: json, whatever: value });
                  

                  您可以使用它来构建 API,在其中将回调函数的名称作为请求查询字符串参数传递.这是一个这样的 API 示例

                  You can use that to build APIs, where you pass the name of a callback function as a request querystring parameter. Here's an example of such an API

                  这篇关于跨域 JSON 请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  SCRIPT5: Access is denied in IE9 on xmlhttprequest(SCRIPT5:在 IE9 中对 xmlhttprequest 的访问被拒绝)
                  XMLHttpRequest module not defined/found(XMLHttpRequest 模块未定义/未找到)
                  Show a progress bar for downloading files using XHR2/AJAX(显示使用 XHR2/AJAX 下载文件的进度条)
                  How can I open a JSON file in JavaScript without jQuery?(如何在没有 jQuery 的情况下在 JavaScript 中打开 JSON 文件?)
                  How do I get the HTTP status code with jQuery?(如何使用 jQuery 获取 HTTP 状态码?)
                  quot;Origin null is not allowed by Access-Control-Allow-Originquot; in Chrome. Why?(“Access-Control-Allow-Origin 不允许 Origin null在铬.为什么?)

                  <legend id='Sba9q'><style id='Sba9q'><dir id='Sba9q'><q id='Sba9q'></q></dir></style></legend>

                          <tbody id='Sba9q'></tbody>
                        1. <tfoot id='Sba9q'></tfoot>
                        2. <small id='Sba9q'></small><noframes id='Sba9q'>

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