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

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

    2. <tfoot id='eoMYV'></tfoot>

        <bdo id='eoMYV'></bdo><ul id='eoMYV'></ul>
    3. <legend id='eoMYV'><style id='eoMYV'><dir id='eoMYV'><q id='eoMYV'></q></dir></style></legend>

        $.ajax 调用在 IE8 中运行良好,但在 Firefox 和 chr

        时间:2023-10-15

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

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

                  <tbody id='nHrpS'></tbody>
                • <bdo id='nHrpS'></bdo><ul id='nHrpS'></ul>
                  <tfoot id='nHrpS'></tfoot>
                • <i id='nHrpS'><tr id='nHrpS'><dt id='nHrpS'><q id='nHrpS'><span id='nHrpS'><b id='nHrpS'><form id='nHrpS'><ins id='nHrpS'></ins><ul id='nHrpS'></ul><sub id='nHrpS'></sub></form><legend id='nHrpS'></legend><bdo id='nHrpS'><pre id='nHrpS'><center id='nHrpS'></center></pre></bdo></b><th id='nHrpS'></th></span></q></dt></tr></i><div id='nHrpS'><tfoot id='nHrpS'></tfoot><dl id='nHrpS'><fieldset id='nHrpS'></fieldset></dl></div>
                • 本文介绍了$.ajax 调用在 IE8 中运行良好,但在 Firefox 和 chrome 浏览器中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  这是我的代码

                  $.ajax(
                  {
                      type: "GET", 
                      url: 'http://devserver:7995/stdpart/services/GetAllPartsWithFilter',
                      dataType: 'json',
                      data: jsonPartsData,
                      success: fnGetPartsData, 
                      error: PartsLoadError  
                  });
                  

                  这是代码在 IE8 中运行良好,但在 Firefox 和 Chrome 浏览器中运行失败.当我检查 XHR 对象时,它表示状态代码为 0.我检查了所有其他问题,但没有一个问题能帮助我识别问题.

                  This is code working fine in IE8, But getting failed in Firefox and Chrome browsers. When i, inspect the XHR object, it's saying the status code code is 0. I have checked all other questions, none of them are helped me to identify the issue.

                  如果我在这段代码中做错了什么,请告诉我.如果 $.ajax 有一些兼容性问题,那么请提出与之等效的建议.

                  Let me know, if i am doing any thing wrong in this code. If $.ajax has some compatibility issues, then please suggest something equivalent to it.

                  更新:我们在以下位置找到了一种解决方案http://www.xml.com/pub/a/2005/12/21/json-dynamic-script-tag.html

                  Update: We found one solution at http://www.xml.com/pub/a/2005/12/21/json-dynamic-script-tag.html

                  它使用了动态脚本的概念.我们在我们的应用程序中做了同样的事情,然后每件事现在似乎都在工作.还是要全面分析.

                  It is using the concept of Dynamic Scripting. We have done the same thing in our application, then every thing seems to be working now. Yet to analyze fully.

                  推荐答案

                  这是因为 同源政策.您不能使用 ajax 调用外部站点.如果你真的想使用,你必须使用 JSONP.或者您可以为此使用服务器端代理.意思是,在服务器端调用外部站点并对那个 web 服务进行 ajax 调用.

                  this is because of the Same origin policy. you cannot use ajax to call external sites. if you really want to use, you have to use JSONP. Or you can use serverside proxy for this. means, call external site in the server side and do ajax call to the that webservice.

                  更新:

                  在您的网站中创建 webserviceice,并在 webmethod 中输入以下代码

                  create webserveice in your site and in the webmethod put following code

                  string proxyURL = "http://devserver:7995/stdpart/services/GetAllPartsWithFilter";
                  HttpWebRequest request = (HttpWebRequest)WebRequest.Create(proxyURL);
                  request.Method = "GET";
                  HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                  
                  if (response.StatusCode.ToString().ToLower() == "ok")
                  {
                      Stream content = response.GetResponseStream();
                      StreamReader contentReader = new StreamReader(content);         
                      return contentReader.ReadToEnd();
                  }
                  return string.Empty;
                  

                  然后使用您的代码访问本地服务.

                  then access local service using your code.

                  更多信息请参考这个链接

                  这篇关于$.ajax 调用在 IE8 中运行良好,但在 Firefox 和 chrome 浏览器中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:我如何知道 jQuery 是否有待处理的 Ajax 请求? 下一篇:WebKit “拒绝设置不安全的标头‘内容长度’&qu

                  相关文章

                  最新文章

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

                  • <bdo id='EDu42'></bdo><ul id='EDu42'></ul>

                    1. <small id='EDu42'></small><noframes id='EDu42'>

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