webbrowser ajax 跨域 办法

 

因为要用webbrowser,打开网页自动完成一些操作,当中要用ajax请求一些数据:

 

但webbrowser内核是IE10,没办法ajax跨域。

网上找了一下解决办法:打开IE->工具-》Internet选项-选安全Tab

 

 

 

点自定义级别 在里面找到“跨域浏览窗口和框架” 选中“启用”按钮,确定保存

 

 

如果是IE7 请启用 以下三项

 

 

 

 

 

  

 

如果是英文版本的IE,设置如下

 

 

 

 用jquery的ajax请求:

jQuery.support.cors = true;
 jQuery.ajax({
    type: "post",
    url: postUrl,
    data: jsondataStr,
    contentType: "application/json;charset=UTF-8",
    crossDomain: true,
    dataType: 'json',
    success: function (data) { 
       //ajax ok
    },
    error: function (XMLHttpRequest, textStatus, errorThrown){
       //erroro
   }    
});

 

 
posted @ 2021-04-22 16:54  为乐而来  阅读(152)  评论(0)    收藏  举报