Jquery ajax调用 WebService
时间:2011-09-06
来源:互联网
C# code
JScript code
返回的error信息:parsererror,在网上找了一中午的帖子,愣是没找到是什么原因。。
using System; using System.Web; using System.Collections; using System.Web.Services; using System.Web.Services.Protocols; using System.Web.UI.MobileControls; using SG_Soft_SqlDAL; using System.Web.Script.Services; /// <summary> /// Hello 的摘要说明 /// </summary> [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [ScriptService] public class Hello : System.Web.Services.WebService { public Hello() { //如果使用设计的组件,请取消注释以下行 //InitializeComponent(); } [WebMethod] public string HelloWorld() { return "Hello World"; } /// <summary> /// 查询类别的返回参数 /// </summary> /// <returns>总记录数</returns> [WebMethod] public string GetCategoryCount() { CategoryMan cm = new CategoryMan(); int count = cm.GetCategoryCount(); return count.ToString(); } }
JScript code
$.ajax({ url:"Hello.asmx/GetCategoryCount", type:"POST", dataType:"json", contentType:"application/json;charset=utf-8", success:function(msg){ var json = null; try { json = eval('('+msg+')'); }catch(e) { alert("返回字符串不是JSON格式。"); return; } alert(msg); }, error:function(err,status) { alert(status); } });
返回的error信息:parsererror,在网上找了一中午的帖子,愣是没找到是什么原因。。
作者: w290601645 发布时间: 2011-09-06
不用json 用text 是没问题的。
作者: w290601645 发布时间: 2011-09-06
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28