$(".common").load("./common.html");
或者這樣寫
$(function(){
$.ajax({
url: 'common.html',
dataType: 'html',
success: function (res) {
$(".common").html(res);
},
error: function(e){
console.log(e);
}
});
});
有時寫的html時需用到本地的文件,在chrome中不能正常運行,用開發(fā)人員工具看到是這樣的一個問題。

報錯
在chrome中可以用--allow-file-access-from-files 命令來解決這個問題。右鍵點擊chrome的快捷方式選擇屬性。在目標一欄中添加--allow-file-access-from-files,如圖所示,注意與前面的內(nèi)容要用一空格隔開。然后從這個快捷方式打開瀏覽器,html便可正常運行。注意,必須通過這個帶有--allow-file-access-from-files命令的快捷方式打開的瀏覽器才行。

chrome