JavaScript代码,巧用JSON传参数
function AddComment(content) {
var comment = {};
comment.threadId = $("#span_thread_id").html();
comment.groupId = $("#span_group_id").html();
comment.groupType = $("#span_group_type").html();
comment.title = $("#thread_title").html();
comment.content = content;
$.ajax({
url: '/WebService/GroupService.asmx/AddThreadComment',
data: $.toJSON(comment),
type: 'post',
dataType: 'json',
contentType: 'application/json;charset=utf-8',
cache: false,
success: function(data) {
//根据返回值data.d处理
},
error: function(xhr) {
//中间发生异常,具体查看xhr.responseText
}
});
}
相关文章
- vue-resource jsonp接口传参-json传参
- 巧用golang的context减少方法传参
- JSONObject的问题- 在用JSONObject传参到controller接收为空白和JSONArray添加json后转string不正确...
- java中http请求调用接口 传参为json格式
- Postman传参的JSON格式
- jquery-uploadify传参方法
- 《springboot》后端接收Content-Type :application/json类型的数据, 前端传参
- SpringMVC(Thymeleaf)向JQuery传参
- 前端post请求方式传参参数各种格式详解,form-data,application/x-www-form-urlencoded,application/json,text/xml
- jquery mobile changepage的三种传参方法介绍