0
嘿,我们试图通过JSON从我们的web api检索数据。这 是我们的JSON对象的样子:从Web API获取JSON通过ASP.NET C#
链接:
http://localhost:51437/api/values
<ArrayOfMessage xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Entities">
<Message>
<Get_Avsändare>0</Get_Avsändare>
<Get_Datum>2012-12-14 12:12:12</Get_Datum>
<Get_Meddelande>hejsan</Get_Meddelande>
<Get_Mottagare>0</Get_Mottagare>
<Get_Savsändare i:nil="true"/>
<Get_Smottagare>Hanna</Get_Smottagare>
</Message>
<Message>
<Get_Avsändare>0</Get_Avsändare>
<Get_Datum>2012-12-14 12:12:12</Get_Datum>
<Get_Meddelande>svejassa</Get_Meddelande>
<Get_Mottagare>0</Get_Mottagare>
<Get_Savsändare i:nil="true"/>
<Get_Smottagare>Hanna</Get_Smottagare>
</Message>
<Message>
<Get_Avsändare>0</Get_Avsändare>
<Get_Datum>2012-12-14 12:12:12</Get_Datum>
<Get_Meddelande>lalala</Get_Meddelande>
<Get_Mottagare>0</Get_Mottagare>
<Get_Savsändare i:nil="true"/>
<Get_Smottagare>Hanna</Get_Smottagare>
</Message>
<Message>
<Get_Avsändare>0</Get_Avsändare>
<Get_Datum>2012-12-14 12:12:12</Get_Datum>
<Get_Meddelande>hejsan</Get_Meddelande>
<Get_Mottagare>0</Get_Mottagare>
<Get_Savsändare i:nil="true"/>
<Get_Smottagare>Hanna</Get_Smottagare>
</Message>
<Message>
<Get_Avsändare>0</Get_Avsändare>
<Get_Datum>2012-12-14 12:12:12</Get_Datum>
<Get_Meddelande>svejassa</Get_Meddelande>
<Get_Mottagare>0</Get_Mottagare>
<Get_Savsändare i:nil="true"/>
<Get_Smottagare>Hanna</Get_Smottagare>
</Message>
</ArrayOfMessage>
这是我们的JSON电话:
function Get_5Messages()
{
$.getJSON(
'Link',
function (data) {
for (var k = 0; k < data.result.length; k++) {
$('#div_Meddelande').text("Kontoret nedstängt" + data[i].Get_Meddelande);
}
}
);
}
如何任何建议解决这个问题? 请帮忙我们用google搜索,但是还没有找到答案
这不是JSON,也就是XML。 – dherman
您在问题中放入的“JSON”实际上是XML,可能是第一个问题:您将错误的数据类型返回给浏览器。其次,你发布的链接是localhost,这是你的电脑。没有人能看到那个链接,但你。 –