次のコードがあります。#testボタンをクリックすると、コンテンツが#currentActivitiesに生成されます。#currentActivitiesのコンテンツを単純に非表示にする別の#hideボタンがあります。私の問題は、初めて#testをクリックしたときに、コンテンツを取得できることです。#hideをクリックすると、#currentActivitiesのコンテンツが期待どおりに非表示になります。ただし、もう一度#testをクリックすると、コンテンツを生成できません。$('#currentActivities').empty();
最初に追加しようとしましたが、うまくいかないようです。誰かが私を助けて私の問題を指摘できますか?
$("#test").click(function() {
$('#currentActivities').empty();
$.ajax({
type: "GET",
dataType: "jsonp",
jsonpCallback: "jsoncallback",
data: {
//some data here
},
url: "http://mydomain.com/check.php?jsoncallback=?",
success: function(data) {
$.each(data, function(index, student) {
$('#currentActivities').append(
'<li><a href="tutor_student_detail.html" data-name="' + data[index].data.NameA + '">' +
'<h4>' + data[index].data.NameA + '</h4>' +
'<p>' + data[index].data.NameA + '</p>' +
'</a></li>');
$("li a").click(function() {
window.localStorage["view"] = $(this).data('name');
window.localStorage["Request"] = "true";
}); //end of li a
});
$('#load2').hide();
$('#filter').show();
$('#currentActivities').listview('refresh');
},
error: function(jqXHR, textStatus) {
alert("Request failed: " + textStatus);
}
});
return false;
});