一般
function URLStatusCheck(url,ifSuccess) {
$.ajax(url, {
contentType: "application/json; charset=utf-8",
dataType: 'jsonp',
crossDomain: true
})
.done(function (data, textStatus, jqXHR) {
ifSuccess.call(null,data)
})
.fail(function (jqXHR, textStatus, errorThrown) {
alert("error");
})
.always(function() {
//alert("complete");
});
}
:その後、
function loadCss(cssText, callback){
var style = document.createElement('style');
style.type='text/css';
if(callBack != undefined){
style.onload = function(){
callBack();
};
}
style.innerHTML = cssText;
head.appendChild(style);
}
URLStatusCheck("http://path/to/file.css",function(cssContent){
loadCss(cssContent,function(){
console.log("New Css has been loaded")
})
})
その後、foは同じ概念を行いますRその他:loadImg
、loadJS
....
http://stackoverflow.com/questions/28164462/catching-failed-to-load-resources-errors-caused-by-html-tags-in-a-webview – Atticweb