微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

WebBrowser中注入js后ajax报错No Transport 或message":"拒绝访问 ","description":"拒

在使用Webbrowser中注入js,

1.用jquery执行ajax时报错 "No Transport"

2.然后添加 jQuery.support.cors = true;  并ajax参数添加crossDomain: true,

  还是报错:{"message":"拒绝访问。","description":"拒绝访问。","number":-2147024891,"name":"Error"}

3.然后查了一下:按下面设置

打开IE:“工具->Internet 选项->安全->Internet->自定义级别”将“其他”选项中的“通过域访问数据源”选中为“启用”

 

 

4.点确定,再把“启用保护模式(要求重启Internet Explorer) 的勾选去了,再保存请求成功。

 

 请求的ajax代码如下:

var postUrl = 'http://127.0.0.1/webApi/findOne.do';
    var postData = {
        "data": {
            "jobUUID": "111"
        }
    };
    var jsondataStr = $jsonStringify(postData)
    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) {
            $log("\najax ok")
            $log("\ndata:" + $jsonStringify(data));
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            $log("\najax.textStatus:" + $jsonStringify(textStatus));
            $log("\najax.errorThrown:" + $jsonStringify(errorThrown));
            //console.log(error);
        }
    });

 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐