ajax 提交表单
/* //提交表单
var url = "product/add.do";
var param = "name=" + document.getElementById("name").value
+ "&name_tw="+ document.getElementById("name_tw").value
+ "&name_en="+ document.getElementById("name_en").value
+ "&code="+ document.getElementById("code").value
+ "&cp="+ document.getElementById("cp").value
+ "&productBiztype="+ document.getElementById("productBiztype").value
+ "&duration="+ document.getElementById("duration").value
+ "&price="+ document.getElementById("price").value
+ "&description="+ document.getElementById("description").value
+ "&description_tw="+ document.getElementById("description_tw").value
+ "&description_en="+ document.getElementById("description_en").value
+ "&description_cp="+ document.getElementById("description_cp").value
;
//catagory
var catagory = document.getElementById("thirdCatagory").value;
if(catagory==0){
var catagory = document.getElementById("secondCatagory").value;
}
if(catagory==0){
var catagory = document.getElementById("catagory").value;
}
//status
var allItem = document.getElementsByName("status");
var index;
for ( var i = 0; i < allItem.length; i++) {
if (allItem.item(i).checked) {
index = allItem.item(i).getAttribute("value");
break;
}
}
//最终参数
param = param + "&catagory=" + catagory + "&status=" + index;
if (window.XMLHttpRequest) {
httpRequest = new XMLHttpRequest();
} else if (window.ActiveXObject) {
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
if (httpRequest) {
httpRequest.open("post", url, true);
httpRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8");
//指定回调函数为
httpRequest.send(param);
httpRequest.onreadystatechange = call;
} */
//$('#myModal').modal('hide');
}
/* //回调函数
function call() {
if (httpRequest.readyState == 4) {
if (httpRequest.status == 200) {
var result = httpRequest.responseText;
if(result=='1')
{
//显示插入成功
setTimeout("$('#myModal').modal('hide')",1000);
setTimeout("noty({'text':'插入成功','layout':'bottomLeft','type':'success'})",1000);
//noty({"text":"插入成功","layout":"bottomLeft","type":"success"});
if(document.getElementById("clearSelect").checked){
//清空文本框
$("input[type=reset]").trigger("click");
}
}else{
//insert fail
setTimeout("$('#myModal').modal('hide')",1000);
setTimeout("noty({'text':'插入失败 请检查参数','layout':'bottomLeft','type':'error'})",1000);
//noty({"text":"插入失败 请检查参数","layout":"bottomLeft","type":"error"});
}
} else {
setTimeout("$('#myModal').modal('hide')",1000);
setTimeout("noty({'text':'插入失败 请检查参数','layout':'bottomLeft','type':'error'})",1000);
}
}
} */