前端之家收集整理的这篇文章主要介绍了
ajax等待效果,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
后台处理参数,生成结果数据:
data['plan_list'] = plans//data是字典
req.send(json.dumps(data).encode('utf-8'))//转成json数据
前台传送参数,接收结果
$.ajax({
type:'post',url:"/myTrac/projectmanage/project/plan_project",data:{
"new_plan_flag":'1',"plan_name":$('#plan_name_new').val(),"project_name":project_name,"stage_list":stage_list.join('[flag]'),__FORM_TOKEN:$('#trac_form_token').val()
},async:true,//false无效果
beforeSend: function(){
var height = document.body.scrollWidth + "px";//滚动位置可能大于屏幕高度
$('#bg').css("display","block").css("height",height).css("text-align","center").html('<img style="padding-top:300px;" src="/myTrac/chrome/projectmanage/images/wait.gif" />');
},complete:function(data) {$('#bg').css("display","none");},//#bg是遮蔽层div
success:function(data){
data = eval("("+data+")");//解析json数据
if(data.status = "Success"){
alert("已保存")
}else{
alert('Create Fail,Please Check !')
}
}
});