Call routine
[javascript] show_Msg('The title should be long', 'Here you can write HTML such as bold font', 'Delete', function(e){
alert(e);
}, 'Here is the data I passed after clicking delete');
show_Msg('The title should be long', 'You can write HTML here such as bold font', 'Delete', function(e){
alert(e);
},'Here is the data I passed after clicking delete');
[javascript] function admin_content_del (id) {
var data=listData[id];
Show_Msg('Confirm deletion',data.content,'Confirm deletion',function(delId){
$.ajax({
url: 'http://localhost/l/index.php',
type: 'get',
dataType: 'json',
data: {
m: 'admin',
a: 'delcontent',
id: delId
},
Complete: function(xhr, textStatus) {
//called when complete
},
Success: function(data, textStatus, xhr) {
If(data.state='ok'){
admin_content(1);
show_Msg_success('Deletion successful');
}else{
show_Msg_success('Deletion failed');
},
error: function(xhr, textStatus, errorThrown) {
//called when there is an error
});
},data.id);
}
function admin_content_del (id) {
var data=listData[id];
show_Msg('Confirm deletion',data.content,'Confirm deletion',function(delId){
$.ajax({
URL: 'http://localhost/l/index.php',
}else{
Show_Msg_success('Deletion failed');
}
},
error: function(xhr, textStatus, errorThrown) {
//called when there is an error
}
});
},data.id);
}
2. setTimeout delays the execution of events. This message is really good and very commonly used, but this method of clearing messages is simple and crude.
[javascript] /**
* 用于显示顶部消息。显示的消息3秒后自动销毁。
* 参数 content 消息内容
* 参数 face 消息的样式,真,为成功绿色的;假,为错误红色的
*/
function show_Msg_success(content,face){
if (face==null) {
face=true;
}
3. It is better to use pure DOM to select checkbox. The arrt() method of jquery is cheating
checkbox.attr('checked',$(this).get()[0].checked);
The checkbox is checked, but it works for the first time and also for the second time. After the third time, it strangely fails. The problem is not the truth.
[javascript] function click_tr() {
var checkbox = $("#mainData tr input");
4. After talking so much, there are no renderings.
5. The title says it’s about PHP practice, but the previous posts are all PHP codes. . Posted below is the php code for batch deletion
[php] /**
* Used to delete messages in batches */
function batchDelContent(){
$json['state']="no";
$data=Array();
$arr=$_POST['delcontent'];
If (count($arr)>0) {
$json['state']="ok";
}
var mainData = $("#main #mainData");
mainData.html(table_html);
mainData.append(page_html);
admin_content_page(page_page,page_end); //Hook paging click event
Click_tr (); // Hang the click event;
//alert(json.data);
},
error: function(xhr, textStatus, errorThrown) {
//called when there is an error
}
});
}
/**
* On-hook paging event
* Parameter page_page current page
* Parameter page_end Number of pages */
function admin_content_page(page_page,page_end) {
$("#mainPage a").click(function() {
var charStr = $(this).text();
var num = charStr;
If (charStr == "»") {
num = parseInt(page_page) + 1;
If (page_end < num) {
Return;
} else if (charStr == "«") {
num = parseInt(page_page) - 1;
If (num <= 0) {
Return;
}
admin_content(num);
});
}
function getLocalTime(nS) {
Return new Date(parseInt(nS) * 1000).toLocaleString().replace(/:d{1,2}$/, ' ');
}
$.ajax({
url: 'http://localhost/l/admin.php?m=admin&a=batchDelContent',
type: 'POST',
dataType: 'json',
data: {delcontent: listId
},
complete: function(xhr, textStatus) {
//called when complete
},
success: function(json, textStatus, xhr) {
if(json.state=='ok'){
var data = json.data;
for (var i = 0; i < data.length; i++) {
if(data[i]['state']=='ok'){
show_Msg_success(data[i].id + '删除成功');
}else{
show_Msg_success(data[i].id + '删除失败',false);
}
};
}else{
}
admin_content(1);
},
error: function(xhr, textStatus, errorThrown) {
//called when there is an error
}
});
// alert(listId);
}
/**
* Used to display dialog message box
* Parameter title message title
* Parameter content message content
* Parameter buttomTitle is a customized button for processing messages, such as confirm deletion
* Parameter fun custom button click event
* The parameter passOnData is passed to the parameter in the custom fun */
function show_Msg (title,content,buttomTitle,fun,passOnData) {
$("#msg #myModalLabel").html(title);
$("#msg .modal-body").html(content);
$('#msg #msg_c').html(buttomTitle).click(function(){
fun(passOnData);//调用自定义的函数,以及传递自定义的数据
$('#msg').modal('hide');//点击完就把窗口隐藏了
$(this).unbind('click');//如果不取消事件,那么将重复调用。。
});;
$('#msg').modal('show');
}
/**
* 用于显示顶部消息。显示的消息3秒后自动销毁。
* 参数 content 消息内容
* 参数 face 消息的样式,真,为成功绿色的;假,为错误红色的
*/
function show_Msg_success(content,face){
if (face==null) {
face=true;
}
//show_Msg_content('Ahhhhhhhhhhhhhhhhhhhhhhhh income tax')
/*
show_Msg('The title should be long', 'You can write HTML here such as bold font', 'Delete', function(e){
alert(e);
},'Here is the data I passed after clicking delete');
*/
function click_tr() {
var checkbox = $("#mainData tr input");
//alert(json.data);
},
error: function(xhr, textStatus, errorThrown) {
//called when there is an error
}
});
}
/**
* On-hook paging event
* Parameter page_page current page
* Parameter page_end Number of pages */
function admin_content_page(page_page,page_end) {
$("#mainPage a").click(function() {
var charStr = $(this).text();
var num = charStr;
if (charStr == "»") {
num = parseInt(page_page) + 1;
if (page_end < num) {
return;
}
} else if (charStr == "«") {
num = parseInt(page_page) - 1;
if (num <= 0) {
return;
}
}
admin_content(num);
});
}
function getLocalTime(nS) {
return new Date(parseInt(nS) * 1000).toLocaleString().replace(/:d{1,2}$/, ' ');
}
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn