我想使用jQuery发送一个AJAX请求。调用url需要授权。直接在浏览器中输入URL,浏览器的授权/登录对话框弹出。如何使用此凭据或使用jQuery强制弹出对话框?
$.ajax({
type: "GET",
url: "myURL",
data: { param1: "1"},
contentType: 'application/json',
dataType: 'json',
success: function( data, textStatus, jQxhr ){
console.log( data );
},
error: function( jqXhr, textStatus, errorThrown ){
console.log( errorThrown );
}
});
发布于 2017-10-05 19:11:56
每当iframe.中的身份验证失败时,都会呈现相同的页面
var url = "your website url here"
$.ajax({
type: "GET",
url: "myURL",
data: { param1: "1"},
contentType: 'application/json',
dataType: 'json',
success: function( data, textStatus, jQxhr ){
console.log( data );
},
error: function( jqXhr, textStatus, errorThrown ){
if(jqXhr.status==401){
$('<iframe src="'+url+'"></iframe>').appendTo('body');
}
}
});https://stackoverflow.com/questions/46584181
复制相似问题