AJAX를 처음 사용했습니다. 링크를 클릭하면 내 페이지 중 하나를로드하려고합니다. (그냥 <a href="something.html">
을 수행 할 수 있음을 알고 있지만 AJAX를 사용하기 위해이 작업을 수행하고 있으며 내 페이지가로드되지만 .? 페이지이 정상 AJAX의 결과이다하지 않습니다 나는 그것이 dataType: html
과 관련이있다 같은데요 여기에 내 코드입니다 :AJAX : 내 자바 스크립트가 콘텐츠로로드되지 않는 이유는 무엇입니까?
function getContent(filename) {
$.ajax({
url: filename,
type: "GET",
dataType: "html",
beforeSend: function(){
$('html').html('<img src="../images/loading.gif">');
},
success: function (data, textStatus, xhr) {
if (filename == "second.html") {
setTimeout(function(){
$('html').html(data);
}, 2000);
} else {
$('html').html(data);
}
},
error: function(xhr, textStatus, errorThrown) {
$('html').html(textStatus);
}
});
}
전체 페이지를로드하는 경우 '위치'만 업데이트하면됩니다. –
여기에서 답변을 찾을 수 있습니다. http://stackoverflow.com/questions/2203762/when-loading-an-html-page-via-ajax-will-script-tags-be-loaded – piatek