ajax 提交方式

前端之家收集整理的这篇文章主要介绍了ajax 提交方式前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

post提交方式:

function delSchedule(){

var scheduleStr = getSelectedSchedule();

if(isPublish == '是'){
alert("不可再进行删除操作!");
return false;
}
if(scheduleStr == null || scheduleStr == ''){
alert("请选择!");
return false;
}
if(!confirm("您确定要删除吗?")){
return false;
}

var paramsStr = "scheduleStr="+scheduleStr;
var url = "/jwcore/delScheduleAction.do";
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded");
xmlHttp.send(paramsStr);
xmlHttp.onreadystatechange = function (){
if (xmlHttp.readyState == 4) {
var response = xmlHttp.responseText;
if(response.indexOf("success") >= 0){
updateHour();
uniteTD();
alert("删除成功!");
return true;
}else{
alert("删除失败!");
return false;
}
}
};

}

get提交方式: function updateTC(rpt){ if(!checkInfo){ return false; } var scheduleStr = getSelectedScheduleUpdate(); //参数字符串 var paramsStr = "?scheduleStr="+scheduleStr; var paramsStr = paramsStr+"&teachingClassID="+document.getElementById('teachingClassID').value; if(typeof(rpt.value2)!="undefined"){ paramsStr = paramsStr+"&teacherID="+rpt.value2; } if(typeof(rpt.value3)!="undefined"){ paramsStr = paramsStr+ "&classroomID="+rpt.value3; } if(typeof(rpt.value6)!="undefined"){ paramsStr = paramsStr+"&assistantTeacherID="+rpt.value6; } if(typeof(rpt.value7)!="undefined"){ paramsStr = paramsStr+"&delAssistantFlag="+rpt.value7; } if(typeof(rpt.value8)!="undefined"){ paramsStr = paramsStr+"&shortName="+rpt.value8; } var url = "/jwcore/editScheduleAction.do"+paramsStr; xmlHttp.open("GET",false); xmlHttp.onreadystatechange = function (){ if (xmlHttp.readyState == 4) { var response = xmlHttp.responseText; if(response.indexOf("success") >= 0){ replaceTC(rpt); alert("编辑成功!"); return true; }else{ alert("编辑失败!"); return false; } } }; xmlHttp.send(null) }

猜你在找的Ajax相关文章