需要 JQuery asmx 调试帮助
如果我能得到任何帮助,我将不胜感激。在我的本地开发中,我能够成功地测试这一点,但是我将相同的代码移到另一台机器上,它似乎不起作用,并且在远程上调试也很困难。所有代码应该做的就是将数据发送到服务器进行处理,但由于某种原因,这根本不起作用。我在服务器端拥有的只是一个框架方法,用于获取发送的任何数据并将其吐出,但由于某种原因,客户端每次都会吐出一个错误,执行下面的代码。
“处理请求时出错。”
function getusersbyselectedrole() {
alert(role_filter);//check to be sure data is being collected
alert("{role :\"" + role_filter + "\"}"); //check to be sure the ride data is being sent to serve
alert("<%= ReportsLink %>/LoadUsersByRole");//check to be sure the right service address is being used
$.ajax({
type: "POST",
url: "<%= ReportsLink %>/LoadUsersByRole",
data: "{role :" + role_filter + "}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
$("#<%= sUsers.ClientID %>").append($("<option></option>").attr("value", "-1").text("select user"));
$.each(msg, function(key, value) {
$("#<%= sUsers.ClientID %>").append($("<option></option>").attr("value", key).text(value));
});
},
error: function(res, status) {
if (status === "error") {
// errorMessage can be an object with 3 string properties: ExceptionType, Message and StackTrace
var errorMessage = $.parseJSON(res.responseText);
alert(errorMessage.Message);
}
}
});
}
I would appreciate any help I can get with this please. In my local dev, I am able to test this successfully, but I moved the same code to another machine and it does not seem to be working, and debugging is hard on the remote as well. All the code ought to do is send data to the server for processing, but for some reason, this is not working at all. All I have on the server end is a skeleton method to get whatever data is sent and spit it back out but for some reason, the client end spits back an error each time, the code below is executed.
"There was an error processing the request."
function getusersbyselectedrole() {
alert(role_filter);//check to be sure data is being collected
alert("{role :\"" + role_filter + "\"}"); //check to be sure the ride data is being sent to serve
alert("<%= ReportsLink %>/LoadUsersByRole");//check to be sure the right service address is being used
$.ajax({
type: "POST",
url: "<%= ReportsLink %>/LoadUsersByRole",
data: "{role :" + role_filter + "}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
$("#<%= sUsers.ClientID %>").append($("<option></option>").attr("value", "-1").text("select user"));
$.each(msg, function(key, value) {
$("#<%= sUsers.ClientID %>").append($("<option></option>").attr("value", key).text(value));
});
},
error: function(res, status) {
if (status === "error") {
// errorMessage can be an object with 3 string properties: ExceptionType, Message and StackTrace
var errorMessage = $.parseJSON(res.responseText);
alert(errorMessage.Message);
}
}
});
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您要将其部署到 IIS 6 吗?如果是这样,问题在于该请求没有任何到 ASP.NET 的映射。您可以在 IIS 6 中解决该问题(见下文),或者只是将 .asmx 添加到您的 URL。它应该已经映射到 Web 服务调用(除非您使用 MVC,在这种情况下您必须将 .asmx 添加到路由规则中)。
http:// /haacked.com/archive/2010/12/22/asp-net-mvc-3-extensionless-urls-on-iis-6.aspx
Are you deploying this to IIS 6? If so, the problem is that the request doesn't have any mapping to ASP.NET. You could either fix the problem in IIS 6 (see below), or just add .asmx to your URL. It should already be mapped to web service calls (unless you are using MVC in which case you would have to add .asmx to your routing rules).
http://haacked.com/archive/2010/12/22/asp-net-mvc-3-extensionless-urls-on-iis-6.aspx