博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Jquery ajax 访问调用带参数的服务方法!
阅读量:4308 次
发布时间:2019-06-06

本文共 1125 字,大约阅读时间需要 3 分钟。

页面脚本中的写法:

$.ajax({            url: "http://localhost:3510/WebSite/WebService/ExceptionRecoder.asmx/SetExceptionInfo",            contentType: "application/json; charset=utf-8",                              type: "POST",                              dataType: "json",                              data: "{mStrException:'"+ e +"'}",            success: function (json) { alert(json.d); }  });

服务写法: 

[System.Web.Script.Services.ScriptService]public class ExceptionRecoder  : System.Web.Services.WebService {    ///     /// 记录前台传入的信息    ///     /// 异常类内容    /// 
[WebMethod(EnableSession = true)] public string SetExceptionInfo(string mStrException) { string errorMethod = null; string remark =""; LogHelper.Instance().WriteErrorLog(BizLogEnum.SystemError.ToString(), mStrException, mStrException,null, errorMethod, remark); return "true"; }}

注意:当前台调用不到带参数的服务时,一般有这两种原因:1可能是因为你前台传参数时候data:拼接参数值不对  2可能是因为服务里面

“//若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。 [System.Web.Script.Services.ScriptService]”这句话可能被注销掉了。

转载于:https://www.cnblogs.com/BeyondWJsel/archive/2012/04/20/2459330.html

你可能感兴趣的文章
Arcsde报ora-29861: 域索引标记为loading/failed/unusable错误
查看>>
记一次断电恢复ORA-01033错误
查看>>
C#修改JPG图片EXIF信息中的GPS信息
查看>>
从零开始的Docker ELK+Filebeat 6.4.0日志管理
查看>>
How it works(1) winston3源码阅读(A)
查看>>
How it works(2) autocannon源码阅读(A)
查看>>
How it works(3) Tilestrata源码阅读(A)
查看>>
How it works(12) Tileserver-GL源码阅读(A) 服务的初始化
查看>>
uni-app 全局变量的几种实现方式
查看>>
echarts 为例讲解 uni-app 如何引用 npm 第三方库
查看>>
uni-app跨页面、跨组件通讯
查看>>
springmvc-helloworld(idea)
查看>>
JDK下载(百度网盘)
查看>>
idea用得溜,代码才能码得快
查看>>
一篇掌握python魔法方法详解
查看>>
数据结构和算法5-非线性-树
查看>>
数据结构和算法6-非线性-图
查看>>
数据结构和算法7-搜索
查看>>
数据结构和算法8-排序
查看>>
windows缺少dll解决办法
查看>>