在我的网站上,我有一个人员列表,其中每个staff
都可以点击。单击后,将打开jquery移动弹出窗口并使用AJAX
加载动态内容。在这里,用户可以选择删除所选择的员工。但是,成功删除后,我需要关闭弹出窗口并刷新人员列表。我认为.trigger("create")
会这样做,但显然不是。
JQuery代码:
$("#dynform").on("click", ".delete_staff", function() {
var delete_staff = $(this).attr("data");
alert("Click is recorded");
$.ajax({
type: "GET",
url: "include/handler/delete.ajax.php?status=-1&type=" + delete_staff,
dataType: "html",
success: function(response) {
alert(response).trigger("create");
}
});
})
答案 0 :(得分:1)
第9行的代码出现严重错误。 请参阅以下示例:
$("#dynform").on("click", ".delete_staff", function() {
var delete_staff = $(this).attr("data");
alert("Click is recorded");
$.ajax({
type: "GET",
url: "include/handler/delete.ajax.php?status=-1&type=" + delete_staff,
dataType: "html",
success: function(response) {
//Let the variable "response" contain the new list, HTML-code generated by the server
//Let the element "dynform" be the list container
//Let the element "myPopup" be the popup you need to close
//Refresh list
$("#dynform").html(response).listview( "refresh" );
//Close popup
$("#myPopup").popup("close");
}
});
})