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
}
//参数结束
});
原文:http://www.cnblogs.com/springran/p/4103970.html