.net jquery ajax应用(前端)
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了.net jquery ajax应用(前端),小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1574字,纯文字阅读大概需要3分钟。
内容图文

//一般处理程序,GET方式提交(data:要传送的数据键值对)
jQuery.ajax(
{ type: ‘GET‘,
url: ‘GradeHandler.ashx?startCount&starDescri‘,
data: { startCount: startCount, starDescri: starDescri }, //(对)
// data: ‘{ startCount:"‘ + startCount + ‘",starDescri:"‘ + starDescri + ‘"}‘, (错)
contentType: "application/json; charset=utf-8",
dataType: ‘json‘,
success: function (result) {
if (result)//返回true
alert(‘评分成功!‘);
else
alert(‘评分失败‘ + result);
},
error: function () {
alert("ajax调用错误");
}
}
);
//一般处理程序,POST方式提交(data:要传送的数据键值对)
jQuery.ajax(
{ type: ‘POST‘,
url: ‘GradeHandler.ashx‘,
data: { startCount: startCount, starDescri: starDescri }, //(对)
// data: ‘{ startCount:"‘ + startCount + ‘",starDescri:"‘ + starDescri + ‘"}‘, //(错)
// contentType: "application/json; charset=utf-8", //不能添加该参数
dataType: ‘json‘,
success: function (result) {
if (result)//返回true
alert(‘评分成功!‘);
else
alert(‘评分失败‘ + result);
},
error: function () {
alert("ajax调用错误");
}
}
);
/*
jQuery调用WebService的方法(只能发送post方式的请求);
返回json格式的数据时,需设置contentType为application/json (data要用Json的字符串格式传入)
返回的数据是以字母d为键值的json对象。
*/
jQuery.ajax(
{ type: ‘POST‘,
url: ‘WebService/GradeWebService.asmx/UserGrade‘,
data: ‘{ count:"‘ + startCount + ‘",descri:"‘ + starDescri + ‘"}‘, //(对)
// data: { count: startCount, descri: starDescri }, //(错)
contentType: "application/json; charset=utf-8",
dataType: ‘json‘,
success: function (result) {
if (result.d)//返回true
alert(‘评分成功!‘ + result.d);
else
alert(‘评分失败‘ + result.d);
},
error: function () {
alert("ajax调用错误");
}
}
);
原文:http://www.cnblogs.com/xiaowei-blog/p/4293076.html
内容总结
以上是互联网集市为您收集整理的.net jquery ajax应用(前端)全部内容,希望文章能够帮你解决.net jquery ajax应用(前端)所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。