- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有两个文本框,我试图将其用于自动完成。两者的源数据均来自 ASP.NET ASMX Web 服务,以 JSON 格式返回。我正在返回一个 List,其中 NameValue 定义为:
public struct NameValue { 公共(public)字符串名称;公共(public)字符串值; }
如何解析此数据,以便可以将所选下拉列表名称的值存储在隐藏字段中?
这是页面加载时到目前为止我的代码,msg.d
包含 JSON 数据(我看到 msg.d[0].Name
和 >msg.d[0].Value
)
$.ajax({
type: "POST",
url: '/Services/Team.asmx/GetClubTeams',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
$('#<%= txtFromTeam2.ClientID %>, #<%= txtToTeam2.ClientID %>').autocomplete({
source:msg.d
});
},
error: function(xhr, msg) {
alert(msg);
}
});
最佳答案
回答了我自己的问题。诀窍是要知道名称/值应采用以下形式:
public struct TeamData { 公共(public)字符串 key ;公共(public)字符串值; }
看来值
(小写)对 jQuery 很重要。
$.ajax()
调用如下...希望这对某人有帮助:
$.ajax({
type: "POST",
url: '/Services/Team.asmx/GetClubTeams',
contentType: "application/json; charset=utf-8",
dataType: "json",
data: "{}",
success: function(data) {
$('#txtFromTeam2').autocomplete({
source: data.d,
minLength: 3,
focus: function(event, ui) {
$('#txtFromTeam2').val(ui.item.value);
return false;
},
select: function(event, ui) {
$('#txtFromTeam2').val(ui.item.value);
$('#<%= txtFromTeam2Id.ClientID %>').val(ui.item.key);
populatePlayers(ui.item.key);
return false;
}
});
$('#txtToTeam2').autocomplete({
source: data.d,
minLength: 3,
focus: function(event, ui) {
$('#txtToTeam2').val(ui.item.value);
return false;
},
select: function(event, ui) {
$('#txtToTeam2').val(ui.item.value);
$('#<%= txtToTeam2Id.ClientID %>').val(ui.item.key);
return false;
}
});
},
error: function(xhr, msg) {
alert(msg);
}
});
关于jQuery 通过 JSON 自动完成来自 ASMX 的名称/值对,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4126925/
我有一个 asmx 服务,它接受一个 int 参数。我可以打开服务的 URL 并查看服务描述屏幕。从这里我可以将查询参数输入表单并调用 Web 服务。 有没有办法直接从 URL/查询字符串调用 Web
我有一个通过 SSL 连接运行良好的 ASMX Web 服务,但我想让这些 Web 服务在没有 SSL 的情况下无法访问。 在网络表单中,我只会使用以下代码: if (!Request.IsSecur
似乎 ASMX 隐含地不允许使用 OPTIONS 动词。我发布这个问题是因为我使用带有 POST 的 jQuery AJAX 调用,它首先在发出 POST 动词**之前向服务器查询可用的选项。 默认情
所以我发现自己遇到了一个难题。我们的应用程序中有一些旧的 asmx Web 服务,多年来一直运行良好。 突然间,他们停止了构建服务器(CI)上的工作。我说停止工作,因为即使当我导航到服务时显示服务描述
我有一个 C# .net Web 服务,需要限制其访问。我已经要求我的消费者使用用户名和密码来调用该服务。但是,有没有办法限制对实际 asmx 页面和 WSDL 的访问?我需要通过用户名/密码和 IP
描述 我有一个遗留类型 HttpRequestScoped以及使用该服务的遗留 Web 服务。为了解决遗留问题中的服务,我有一个全局解析器。这一切在 1.4 中运行良好,现在我正在使用 2.1.12,
有谁知道 SQL Server Reporting Services 中的两个 Web 服务端点 ReportService2005.asmx 和 ReportExecution2005.asmx 之
我有一个基本的 ASMX 服务,我正在尝试运行它(我宁愿使用 WCF,但无法让服务器使用它)。它在没有安全设置的情况下运行良好,但是一旦我打开安全性,我就会得到: The HTTP request i
在设计 ASMX 网络服务时,对您可以使用的类型有某种限制(序列化/反序列化)。 谁能告诉我这些限制是什么?是否可以通过在代码中添加serializable属性来绕过? 最佳答案 没有。传统的 ASM
我已经使用 CheckVat 方法创建了 ASMX 网络服务。如果我从 https://my.domain.com/VatValidation.asmx 调用此方法,我会得到成功的 json 响应,如
我正在通过经典的 asmx 网络服务传输一个大的压缩文本文件。我这样做的原因是文件的大小是 20 MB 解压缩,4MB 压缩。 这是方法。如有必要,我会提供更多信息。 [WebMethod]
我需要在客户端页面中使用 JavaScript 调用我的 Web 服务方法。我认为我没有正确引用这一点,希望您能帮助解决这一问题。 错误消息显示“CalendarHandler 未定义”。
我正在使用 ASP.NET 和 asmx 服务来访问我的 SQL 数据库的数据。 该服务既称为客户端又称为后端。 该网站将供我们的内部员工和我们的客户使用。 asmx 服务中有一些方法,如果它们未通过
我在一台服务器 1 上编写了一个 asmx 服务,在另一台服务器 2 上编写了 asp.net/c#。 我要转一个dictionary从 srv1 到 srv2。我读到 Dictionary is n
所以我在 Visual Studio 2010 中创建了一个 Web 服务。为了将它部署到 IIS Web 服务器上,我将 service.asmx、web.config 和 bin 复制到服务器(w
我有以下 ASMX 网络服务: // removed for brevity // namespace AtomicService { [WebService(Namespace = "htt
我在我的应用程序中使用第三方支付网关。支付网关提供商为集成提供了测试 asmx HTTPS URL,它有一些方法。使用 HttpWebRequest 我集成到我的应用程序中。我正在发送 SOAPReq
我正在尝试将国家/地区 Web 服务添加到下拉列表中。我已经添加了 Web 引用并拥有 discomap 和 wsdl 文件。 这是我的代码隐藏: net.webservicex.www.countr
我有一个扩展名为 .asmx 的网络服务,它指向我的网络应用程序中的一个类。添加一些代码以在应用程序启动时输出调试日志后,我可以看到每次用户访问该页面时都会创建一个新的调试日志。 我希望我可以将此 W
我有一个 asmx 服务,这些方法返回具有原始数据类型属性的自定义类。当这些属性为 null 时,它们将被排除在服务返回的 xml 之外。我希望该服务仍返回 xml 中的属性,但没有值。有办法做到这一
我是一名优秀的程序员,十分优秀!