在 ASP.Net 4 中从 jQuery 访问 asmx 服务的结果?
我无法访问从我的网络服务返回的结果。当我在 firebug 中监视它时,我可以看到返回的结果是正确的,但我不知道如何访问它们。我收到错误“引用未定义的属性 data.d”
这是调用该服务的代码:
<script type="text/javascript">
$(document).ready(function () {
$("#Button1").click(function () {
$.ajax(
{
contentType: "application/json",
dataType: "json",
type: "POST",
url: "service/myService.asmx/getGameTitles",
data: "{ 'Genre': 'JRPG' }",
complete: Success,
error: Error,
processData: false
})
});
function Success(data, status) {
$("#MainContent_Label1").html(data.d);
}
function Error(request, status, error) {
$("#MainContent_Label1").html(request.statusText);
}
});
</script>
这是我在 firebug 中监视调用时看到的内容:
d ["Game 1", "Game 2"]
0 "Game 1"
1 "Game 2"
并且
Success()
data = Object { readyState=4, responseText="{"d":["Game 1","Game 2"]}", status=200, more...}
status = "success"
我不确定如何访问结果。有什么建议吗?
谢谢!!
I am having trouble accessing the results returned from my web service. When I monitor it in firebug, I can see that the results being returned are correct, but I'm not sure how to access them. I am getting an error "reference to undefined property data.d"
Here is the code that is calling the service:
<script type="text/javascript">
$(document).ready(function () {
$("#Button1").click(function () {
$.ajax(
{
contentType: "application/json",
dataType: "json",
type: "POST",
url: "service/myService.asmx/getGameTitles",
data: "{ 'Genre': 'JRPG' }",
complete: Success,
error: Error,
processData: false
})
});
function Success(data, status) {
$("#MainContent_Label1").html(data.d);
}
function Error(request, status, error) {
$("#MainContent_Label1").html(request.statusText);
}
});
</script>
This is what I see when I monitor the call in firebug:
d ["Game 1", "Game 2"]
0 "Game 1"
1 "Game 2"
and
Success()
data = Object { readyState=4, responseText="{"d":["Game 1","Game 2"]}", status=200, more...}
status = "success"
I'm not sure how to access the results... any tips?
Thanks!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在成功处理程序中,您可以访问结果
in the sucess handler you can access the results as