如何使用javascript将json webservice数据绑定到html表 [英] how to bind json webservice data to html Table using javascript

查看:78
本文介绍了如何使用javascript将json webservice数据绑定到html表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI,



我正在使用以JSON格式返回数据的web服务,我想使用javascript将json数据绑定到HTML表。



Json Webservice输出: -



[{Address_Line_1:331 Bangalore,Address_Line_2: , Address_Line_3: , Address_Line_4: , AlternateAddresses:[], 城市: 班加罗尔, 国家: 印度, 距离: 0, FormattedAddress :3s1班加罗尔,班加罗尔,班加罗尔66,GeoCode:POINT(-34.134345334349056 20.3254345354}]





所以如何使用javascript将上面的json输出绑定到html表。如何在javascript中调用这个Json webservice如何handel输出以及如何绑定到html数据,示例将非常有用。



I am using a webservice which return data as Json format, i want to bind the json data to a HTML table using javascript.

Json Webservice Output :-

[{"Address_Line_1":"331 Bangalore","Address_Line_2":"","Address_Line_3":"","Address_Line_4":"","AlternateAddresses":[],"City":"Bangalore","Country":"India","Distance":"0","FormattedAddress":"3s1 Bangalore, Bangalore, Bangalore 66","GeoCode":"POINT (-34.134345334349056 20.3254345354" }]


so how to bind the above json output to html table using javascript. and how to call this Json webservice in javascript how to handel output and how to bind to html data , a sample will be very helpful.

推荐答案

你好,



有很多种方法可以做到。一种方法是使用 document.createElement( < table>) document.createElement(< tr>) d ocument.createElement( < TD >)。然后,您可以使用 .append 方法将 td 附加到 tr tr ,最后 body 或placehoder div



但是我建议你看一下数据表[ ^ ],SlickGrid [ ^ ]提供'更多功能。



问候,
Hello,

There are many ways you can do it. One way is to use document.createElement("<table">), document.createElement("<tr">) and document.createElement("<td">). You can then use .append method to append the td to tr and tr to table and finally table to either body or placehoder div.

However I will suggest you to have a look at Data Tables[^], SlickGrid[^] which offer''s much more capabilities.

Regards,


这篇关于如何使用javascript将json webservice数据绑定到html表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆