我的代码中有什么问题,因为我想检查连接..? [英] What is the problem in my code as i want to check connection..?

查看:49
本文介绍了我的代码中有什么问题,因为我想检查连接..?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <script type="text/javascript">

      $(document).ready(function() {
        $.support.cors = true;
      });

      function callAjax() {
        $.ajax({
          type: 'GET',
          url: 'http://js.i-parcel.com',
          timeout: 50000000,
          success: function(data) { alert('Connected to i-parcel.'); },
          error: function(XMLHttpRequest, textStatus, errorThrown)
          { alert('Error:\r\n' + textStatus); }
        });
      }

    </script>

 <asp:Button runat="server" id="btnClick" onclientclick="callAjax(); return false;" text="Click Here" xmlns:asp="#unknown" />

    </div>
    </form>
</body>
</html>







当我通过Visual Studio运行时,上面的代码运行正常。但如果我通过IIS运行它会给出错误。或者任何生产服务器..问题只出现在IE浏览器中。

我还使用了$ .support.cors = true;允许CORS。




Above code runs ok when i run it through Visual Studio. But gives error if i run it through IIS. or any production server ..Problem occur in only IE Browser.
I have also used $.support.cors = true; to allow CORS.

推荐答案

(document).ready(function(){
(document).ready(function() {


.support.cors = true;
});

函数callAjax(){
.support.cors = true; }); function callAjax() {


.ajax({
type:'GET',
url:'http:// js .i-parcel.com',
超时:50000000,
成功:功能(数据){alert('连接到i-parcel。');},
错误:function(XMLHttpRequest) ,textStatus,errorThrown)
{alert('错误:\\\\ n'+ textStatus);}
});
}

< / script >

< asp:Button runat = server id = btnClick onclientclick = callAjax(); return false; text = 点击此处 xmlns:asp = #unknown / >

< / div >
< / form >
< / body >
< / html >
.ajax({ type: 'GET', url: 'http://js.i-parcel.com', timeout: 50000000, success: function(data) { alert('Connected to i-parcel.'); }, error: function(XMLHttpRequest, textStatus, errorThrown) { alert('Error:\r\n' + textStatus); } }); } </script> <asp:Button runat="server" id="btnClick" onclientclick="callAjax(); return false;" text="Click Here" xmlns:asp="#unknown" /> </div> </form> </body> </html>







当我通过Visual Studio运行时,上面的代码运行正常。但如果我通过IIS运行它会给出错误。或者任何生产服务器..问题只出现在IE浏览器中。

我也用过




Above code runs ok when i run it through Visual Studio. But gives error if i run it through IIS. or any production server ..Problem occur in only IE Browser.
I have also used


这篇关于我的代码中有什么问题,因为我想检查连接..?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆