【发布时间】:2013-02-28 20:46:06
【问题描述】:
在传递两个参数时,我无法从 jquery 获得 WCF 调用。如果我稍微更改代码以仅通过一件事就可以了。
Javascript:
$.ajax({
type: "POST", //GET or POST or PUT or DELETE verb
url: "/Services/JobNumberService.svc/GetActiveJobNumberByCustomerOrJointBilling", // Location of the service
data: '{"customerId": "' + customerId + '", "departmentId": "' + departmentId + '"}', //Data sent to server
contentType: "application/json; charset=utf-8", // content type sent to server
dataType: "json", //Expected data format from server
processdata: true, //True or False
success: function (msg) {//On Successfull service call
fillDropDownFromLookupList(msg, jobNumberDropDownId);
prependItemToDropDown('', 'NONE', jobNumberDropDownId); //Add blank item to top of list
},
error: ServiceFailed// When Service call fails
});
服务签名:
public LookupList GetActiveJobNumberByCustomerOrJointBilling(int customerId, int departmentId)
这与我格式化传入的 json 的方式有关。根据 JSONLint 它是有效的,但可能不是 .net 所期望的。
感谢您的想法。
编辑
这就是我在回复中得到的回复
HTTP/1.1 500 Internal Server Error
Server: ASP.NET Development Server/11.0.0.0
Date: Thu, 28 Feb 2013 20:30:17 GMT
X-AspNet-Version: 4.0.30319
Cache-Control: private
Content-Length: 0
Connection: Close
哦,我还尝试关闭我的代码调试以跟踪错误是什么,但由于某种原因我没有看到任何异常。
【问题讨论】:
-
尝试逐步执行服务器端执行并查看 500 错误是什么 - 或在配置中打开详细错误消息,以便响应将包含堆栈跟踪。这是相当模棱两可的。
-
嘿,托尼,您想到的详细错误设置在哪里?我在 serviceBehaviors 配置部分有 includeExceptionDetailInFaults="true"。
-
您应该能够通过编辑
web.config来打开它们,如下所示:<system.web><customErrors mode="On" /></system.web>- 如果这不起作用,请告诉我,我会帮助您进一步挖掘。 -
好主意,我已经很遗憾地打开了它
-
嘎——这就是我快速打字的结果。
customErrors需要设置为Off才能获得详细信息。