ajax封装调用
封装的ajax:
function ajaxJson(url,data,callfun) { $.ajax({ type:"POST", url:url, data:data, dataType:'json', success:callfun, error:function(){ $('.modal-body').html('参数丢失,请重新操作一次'); $('#myModal').modal('show'); }, }); }
使用实例:
$('.button_del').click(function(){
var book_id = $(this).attr('book_id');
var own_id = $(this).attr('own_id');
var type = 2; //删除
if(!book_id || !own_id){
$('.modal-body').html('部分参数丢失');
$('#myModal').modal('show');
return false;
}
$(this).attr('disabled',"true"); //添加disabled属性
var url = "<?php echo $this->url->get('index/dealmyrequest');?>";
var data = "book_id="+book_id+"&own_id="+own_id+"&type="+type;
ajaxJson(url,data,function(res){
$('.modal-body').html(res.msg);
$('#myModal').modal('show');
$('#myModal').on('shown.bs.modal',function(e){
$('.button_del').removeAttr("disabled"); //移除disabled属性
});
if(res.flag==1){
$('#modal_confirm').click(function(){
window.location.reload();
});
// //模态框show 完后的回调函数
// $('#myModal').on('shown.bs.modal',function(e){
// window.location.reload();
// });
}
});
return false;
});
1、以专家为榜样,不必自己重新探索
2、解构技能,找出实现80%效果的那20%
3、不要一心二用
4、练习练习再练习!然后获得即时反馈
5、坚持,不要在低谷期放弃
2、解构技能,找出实现80%效果的那20%
3、不要一心二用
4、练习练习再练习!然后获得即时反馈
5、坚持,不要在低谷期放弃

浙公网安备 33010602011771号