为Angular 1.5.8开发程序
当从剪贴板加载和粘贴页面时触发相同的功能,并且出于某种原因,当加载所有内容正常时,但是当你从IE中的剪贴板中粘贴到IE(其他浏览器工作)时函数XMLHttpRequest xhr.open('put','http://localhost:62631/api/PlantConsignee/',true); 我给错误“无效论证”。 当我进行角度换行时,我会收到错误“拒绝访问” PlantConsignee.query( 错误:访问被拒绝。
at anonymous function(http://localhost:62631/prodaction/script/node_modules Oh.min.js?ver = 0.6.6688.17819:125:278)at n(http://localhost:62631/prodaction/script/node_modules Oh.min.js?ver = 0.6.6688.17819:122: 53)匿名函数(http://localhost:62631/prodaction/script/node_modules Oh.min.js?ver = 0.6.6688.17819:119:255)匿名函数(http://localhost:62631/prodaction/script/node_modules Oh.min.js?ver = 0.6.6688.17819:154: 10)at m.prototype。$ eval(http://localhost:62631/prodaction/script/node_modules.min.js?ver=0.6.6688.17819:168:336)at m.prototype。$ digest http://localhost:62631/prodaction/script/node_modules Oh.min.js?ver = 0.6.6688.17819:165:412)at m.prototype 。$ apply(http://localhost:62631/prodaction/script/node_modules.min.js?ver=0.6.6688.17819:169:111)在w.event.dispatch(http://localhost:62631/prodaction/script/node_modules处的匿名函数(http://localhost:62631/prodaction/script/node_modules.min.js?ver=0.6.6688.17819:2 Oh.min.js?ver = 0.6.6688.17819:299:245): 41706)在y.handle(http://localhost:62631/prodaction/script/node_modules Oh.min.js?ver = 0.6.6688.17819:2:39718)
function planttetst() {
console.log("Запрос заводов");
var xhr = new XMLHttpRequest();
xhr.open('put', 'http://localhost:62631/api/PlantConsignee/', true);
xhr.setRequestHeader('Content-Type', 'application/json; charset=utf-8');
var inp = JSON.stringify({ "pageNumber": 1, "pageSize": 9999, "Count": 9999, "Items": [{ "Id": 1, "PlantCode": "**", "Code": "BP00016238" }] });
xhr.send(inp);
xhr.onreadystatechange = function () {
var response = xhr.responseText;
console.log("ответ заводов" + response.toString());
}
PlantConsignee.query({ "pageNumber": 1, "pageSize": 9999, "Count": 9999, "Items": [{ "Id": 1, "PlantCode": "**", "Code": "BP00016238" }] }).$promise.then(function (response) {
console.log("Запрос заводов мал" + (new Date).toString());
alert("super");
}).catch(function (reason) {
notifyService.error("Ошибка при загрузке справочника завод planttetst1" + ((reason === undefined || reason === null || reason.data === undefined) ? "" : reason.data.message) + ". Повторите попытку через 5 минут");
});
}
主要的是,这个错误只发生在IE中,在chrome中一切都可用:/
答案 0 :(得分:0)
我通过在原始AJAX调用上使用setTimeout()解决了这个问题。 E.g:
setTimeout(function() {
XMLHttpRequest xhr.open('put', 'http://localhost:62631/api/PlantConsignee/', true);
}, 1);
我认为这是IE中的某种错误。只需1毫秒就可以了!