jquery post 提交等待 同步处理

post可以实现同步和异步,在不同的场景应用不同的方式。在引导向导中,用户提供表单应该等待服务器返回状态才能进行下一步。

 bootbox.dialog({message: "请耐心等待,正在向服务器提交任务...", });
						//提交创建任务
						console.log('ajax')

						
							$.ajax({
       								type: 'POST',
        							url: '/task/testpost/',
        							async: false,
        							data: {
        									
        									'taskContent':$("#step2_taskcontent").text(),
        									'taskCreatorID':$('#username').text(),

        									'workers[]':$("#step1_workers").val(),
        									'name':'test',
        								},

        							success: function(data){

        								bootbox.hideAll()

										$('#wizard_left').hide()
										//return false

       								 },

       								 error: function(XMLHttpRequest, textStatus, errorThrown) {
       								 	bootbox.hideAll()
       								 	//console.log('error')
                        				//alert(XMLHttpRequest.status);
                       					 //alert(XMLHttpRequest.readyState);
                        				alert("创建服务单失败,可能是网络连接有问题,请与管理员联系。错误:"+textStatus+","+XMLHttpRequest.status+","+XMLHttpRequest.readyState);
										return false
                        			}
									//参数结束

   						 });

 

 
posted @ 2014-11-17 17:09  springran  阅读(3240)  评论(0编辑  收藏  举报