我已经给出了一个JSON webservice链接,在这个链接下我们有数据并希望使用ajax jWuery在html表格上显示它。如果我从IE下载它,它使用.json格式在本地工作,但webservice链接不起作用。我已检查链接是否正常工作,但它在JSON查看器中工作。该怎么办?如何使用jQuery在JSON webservice链接上显示html数据
$(document).ready(function() {
$.ajax({
type: "GET",
data : "{}",
contentType: "application/json",
//url: 'myfile.json',
url: 'http://107.22.160.4/ICatService/Service.svc/GetEvent/10/iphone2x',
dataType: "json",
success: function(data) {
$.each(data.Get_TappyokaResult, function(index, data){
var tblRow = "<tr>"+
"<td>"+data.Back_id+"</td>"+
"<td><img src="+data.Back_image+" class=rowimg /></td>\n"+
"<td>"+data.Back_type+"</td>\n"+
"<td>"+data.DateModified+"</td>"+
"</tr>"
$(tblRow).appendTo(".dataTable");
$('table tr:odd').addClass('oddrow');
$('.dataTable tr:even').addClass('evenrow');
});
},
error: function(data){
alert("error");
}
});
});
myfile.json本地文件---------------------------------
{
"Get_ICatelog_EventResult":[
{
"Date":"26\/07\/2012", "Description":"sample event", "Event_Id":5, "Heading":"sample", "Image":"http:\/\/thisisswitch.com\/ICatalogsite\/EventImage\/fc8e84f2-6729-42c0-8e0e-c6961edd2df5.JPG", "Status":0, "Time":"14:00:00", "User_Id":10
}
]
}
显示您的Web服务链接。也许可以使用'Ajax'。 – hekomobile 2012-08-02 16:00:56