JQuery UI

推荐列表 站点导航

当前位置:首页 > jquery > JQuery UI >

AJAX_jQuery的ajax传参巧用JSON使用示例(附Json插件),jQuery的ajax调用很方便,传参的

来源:网络整理  作者:  发布时间:2020-12-21 21:28
jQuery的ajax传参巧用JSON使用示例(附Json插件),jQuery的ajax调用很方便,传参的时候喜欢用Json的数据格式。比如: 复制代...
dataType: 'json',
//根据返回值data.d判断是不是成功

var groupType = $("#span_group_type").html();

jQuery的ajax调用很方便,传参的时候喜欢用Json的数据格式。比如:
cache: false,
data: $.toJSON(comment),
//中间发生异常,具体查看xhr.responseText
contentType: 'application/json;charset=utf-8',
url: '/WebService/GroupService.asmx/AddThreadComment',
error: function(xhr) {
success: function(data) {

复制代码 代码如下:

error: function(xhr) {
contentType: 'application/json;charset=utf-8',
var groupId = $("#span_group_id").html();


}


function AddComment(content) {
var comment = {};
comment.title = $("#thread_title").html();
}
success: function(data) {
dataType: 'json',
直接用$.toJSON(对象)即可;
var threadId = $("#span_thread_id").html();
});
//中间发生异常,查看xhr.responseText
var title = $("#thread_title").html();
type: 'post',
var content = content.replace(/\x22/g,'"');
comment.groupId = $("#span_group_id").html();
cache: false,
});
},

$.ajax({
}
这中间最麻烦,最容易出错的也是拼接Json字符串,字符型参数的值要添加引号,而且对于用户输入的文本字段要对',/等进行特殊处理

comment.threadId = $("#span_thread_id").html();
data: '{threadId:' + threadId + ',groupId:' + groupId + ',groupType:' + groupType + ',title:"' + title + '",content:"' + content + '"}', type: 'post',
}

复制代码 代码如下:

$.ajax({
comment.content = content;
comment.groupType = $("#span_group_type").html();
jQuery的JSON插件:

意外的机会,上司给我推荐了一种新的方法,看下面代码:
function AddComment(content) {
//根据返回值data.d处理

},
url: '/WebService/GroupService.asmx/AddThreadComment',

相关热词: 调用

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!

本文地址: https://v30.fanwenzhu.com/jq/ui/6795.shtml

最新文章
django 项目怎么创建超级用 django 项目怎么创建超级用

时间:2020-12-19

热门文章
django 项目怎么创建超级用户 django 项目怎么创建超级用户

时间:2020-12-19

Copyright © www.juheyunku.com      关于 | 合作 | 声明 | 联系 | 更新 | 地图 | Tags

AJAX_jQuery的ajax传参巧用JSON使用示例(附Json插件),jQuery的ajax调用很方便,传参的

2020-12-21 编辑:

dataType: 'json',
//根据返回值data.d判断是不是成功

var groupType = $("#span_group_type").html();

jQuery的ajax调用很方便,传参的时候喜欢用Json的数据格式。比如:
cache: false,
data: $.toJSON(comment),
//中间发生异常,具体查看xhr.responseText
contentType: 'application/json;charset=utf-8',
url: '/WebService/GroupService.asmx/AddThreadComment',
error: function(xhr) {
success: function(data) {

复制代码 代码如下:

error: function(xhr) {
contentType: 'application/json;charset=utf-8',
var groupId = $("#span_group_id").html();


}


function AddComment(content) {
var comment = {};
comment.title = $("#thread_title").html();
}
success: function(data) {
dataType: 'json',
直接用$.toJSON(对象)即可;
var threadId = $("#span_thread_id").html();
});
//中间发生异常,查看xhr.responseText
var title = $("#thread_title").html();
type: 'post',
var content = content.replace(/\x22/g,'"');
comment.groupId = $("#span_group_id").html();
cache: false,
});
},

$.ajax({
}
这中间最麻烦,最容易出错的也是拼接Json字符串,字符型参数的值要添加引号,而且对于用户输入的文本字段要对',/等进行特殊处理

comment.threadId = $("#span_thread_id").html();
data: '{threadId:' + threadId + ',groupId:' + groupId + ',groupType:' + groupType + ',title:"' + title + '",content:"' + content + '"}', type: 'post',
}

复制代码 代码如下:

$.ajax({
comment.content = content;
comment.groupType = $("#span_group_type").html();
jQuery的JSON插件:

意外的机会,上司给我推荐了一种新的方法,看下面代码:
function AddComment(content) {
//根据返回值data.d处理

},
url: '/WebService/GroupService.asmx/AddThreadComment',

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供学习参考!
本文地址为 https://v30.fanwenzhu.com/jq/ui/6795.shtml

相关文章

风云图片

推荐阅读

返回JQuery UI频道首页