Следующий код загружает html-контент из файла (я использовал этот поток )
<script>
$.fn.loadWithoutCache = function (){
$.ajax({
url: arguments[0],
cache: false,
dataType: "html",
success: function(data) {
$(this).html(data); // This is not working
//$('#result').html(data); //THIS WORKS!!!
alert(data); // This alerts the contents of page.html
}
});
}
$('#result').loadWithoutCache('page.html');
</script>
Пожалуйста, дайте мне знать, в чем проблема? Надеюсь, это что-то глупое :)
Изменить: ПРАВИЛЬНЫЙ КОД
<script>
$(document).ready(function() {
$.fn.loadWithoutCache = function (){
var $el = $(this);
$.ajax({
url: arguments[0],
cache: false,
dataType: "html",
context: this,
success: function(data) {
$el.html(data);
}
});
}
$('#result').loadWithoutCache('page.html');
});
</scipt>
Спасибо, Джон, и всем!
this
относится к объекту jQuery XHR. - person Rob W   schedule 22.10.2011