$("#btnSend").click(function() {
$("#request-process-patent").html("正在提交数据,请勿关闭当前窗口...");
$.ajax({
type: "POST",
url: "RequestData.ashx",
contentType: "application/json; charset=utf-8",
data: JSON.stringify(GetJsonData()),
dataType: "json",
success: function (message) {
if (message > 0) {
alert("请求已提交!我们会尽快与您取得联系");
}
},
error: function (message) {
$("#request-process-patent").html("提交数据失败!");
}
});
});
function GetJsonData() {
var json = {
"classid": 2,
"name": $("#tb_name").val(),
"zlclass": "测试类型1,测试类型2,测试类型3",
"pname": $("#tb_contact_people").val(),
"tel": $("#tb_contact_phone").val()
};
return json;
}
核心为JSON.stringify()方法,方法说明:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
参考文章:http://www.cnblogs.com/jaxu/p/3698404.html
本文出自 “java程序猿的博客” 博客,请务必保留此出处http://chengxuyuan.blog.51cto.com/5789198/1864856
原文地址:http://chengxuyuan.blog.51cto.com/5789198/1864856