ajaxでhtmlを読み込んだらjsが効かなかったので、その対策メモ。
successしたときに関数をたたいてます。
こんなやり方でいいのかな。
index.thml(ベースとなるhtml)
$(function() {
function loadAjax(){
$.ajax({
url : 'load.html',
type: "GET",
cache: false,
timeout: 11000,
dataType: "html",
async: true,
success : function(data){
$('#loadHTML').html(data);
ajaxJs();
},
error: function(data){
console.log('エラー');
}
});
}
$('#btn').on('click', function () {
loadAjax();
});
});
load.html(ajaxで読み込むhtml)
function ajaxJs() {
console.log('ajax内のjs実行');
}