您好,欢迎访问一九零五行业门户网

jquery 漂亮的删除确认和提交无刷新删除示例_jquery

本例数据库结构很简单,就一个字段就行了
jquery.confirm.js
复制代码 代码如下:
(function($){
$.confirm = function(params){
if($('#confirmoverlay').length){
// a confirm is already shown on the page:
return false;
}
var buttonhtml = '';
$.each(params.buttons,function(name,obj){
// generating the markup for the buttons:
buttonhtml += ''+name+'';
if(!obj.action){
obj.action = function(){};
}
});
var markup = [
'',
'',
'',params.title,'',
'',params.message,'
',
'',
buttonhtml,
'
'
].join('');
$(markup).hide().appendto('body').fadein();
var buttons = $('#confirmbox .button'),
i = 0;
$.each(params.buttons,function(name,obj){
buttons.eq(i++).click(function(){
// calling the action attribute when a
// click occurs, and hiding the confirm.
obj.action();
$.confirm.hide();
return false;
});
});
}
$.confirm.hide = function(){
$('#confirmoverlay').fadeout(function(){
$(this).remove();
});
}
})(jquery);
php code
复制代码 代码如下:
0;
$rs=mysql_query($sql);
if ($row = mysql_fetch_array($rs))
{
do {
?>
javascript code
复制代码 代码如下:
$(document).ready(function(){
$('.item .delete').click(function(){
var elem = $(this).closest('.item');
var id=$(this).attr('id');
$.confirm({
'title' : '删除该记录?',
'message' : '您确认删除该记录?
删除后无法恢复记录.',
'buttons' : {
'yes' : {
'class' : 'blue',
'action': function(){$.ajax({
type: 'get',
url: 'del.php',
data: 'id='+id,
});
elem.slideup();
}
},
'no' : {
'class' : 'gray',
'action': function(){} // nothing to do in this case. you can as well omit the action property.
}
}
});
});
});
del.php
复制代码 代码如下:
其它类似信息

推荐信息