js 表单内容使用ajax以json格式混合提交
脚本代码
function submitForm(){
var post_data = $("#form1").getdict();
var data_dict = {};
$.each(post_data, function(){
data_dict[this.name] = this.value;
});
var article_datum = []; // 相关文章
$("#relation_text li").each(function(){
article_datum.push($(this).attr("data-id"));
});
data_dict["article_datum"] = article_datum;
data_dict["article_data"] = {"css":"","html_banner":"","jianjie_title":""};
var raw_data = JSON.stringify(data_dict);
$("#submit").disabled(); //禁用按钮
$.post(location.href, raw_data, function(data){
$("#submit").disabled({"flag":false});
if(data == "error"){
return alert("保存失败");
}
var d = data.evalJson();
if (d.response == 'ok') { //success
alert("保存成功!");
location.reload();
} else {
alert("保存失败!");
}
});
}