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

 

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

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

webbrowser ajax 跨域  办法

 

 

 

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

 webbrowser ajax 跨域  办法

 

如果是IE7 请启用 以下三项

 

webbrowser ajax 跨域  办法

 

 webbrowser ajax 跨域  办法

 

 

  webbrowser ajax 跨域  办法

 

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

webbrowser ajax 跨域  办法

 

 

 

 用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
   }    
});

 

 

相关文章: