我希望能够将一个 php- supplied json 对象放入 html 。 我的老方法只是制作一个令人难以置信的长不可理解的 html 字符串, 然后做$. append(hltStr)
上次我把它贴在SO上时没有这么好过。 我想知道是否有人能向我解释如何用 < a href=' 将一个 json 对象放入 html 。 http://www.eslinstructor. net/vktemplate/" rel="nofollow" < a > 这个模板 < a > 。 这显然是对 < a href= > "http://ejohn.org/blog/javacrent-micro-templating/ " rel=" nofolpolt > 的改进。
鉴于对象:
{
"order": {
"name": "TRADEMARK WHEEL COMPANY",
"sales_order_id": "18278",
"order_date": "05 u2044 15 u2044 2012",
"due_date": "05 u2044 21 u2044 2012",
"order_number": "1213140",
"reference": "21192D/35546",
"order_description": "BICICLETTE",
"ship_name": "ADAMS",
"ship_address1": "1919 W RANDOLPH ST.",
"ship_address2": "",
"ship_city": "CHICAGO",
"ship_state": "IL",
"ship_postal_code": "60606",
"ship_country": null,
"ship_via": "FEDEX GROUND",
"tracking_number": null,
"package_contents": null,
"freight": "0.00",
"taxable": "0.00",
"nontaxable": "748.88",
"sales_tax": "0.00"
时 时,
"line_item": [{
"description": "RED ONE",
"quantity": "2.00",
"sell_price": "349.44"
时 时,
{
"description": "FRONT GEAR",
"quantity": "2.00",
"sell_price": "15.00"
时 时,
{
"description": "5th GEAR",
"quantity": "2.00",
"sell_price": "10.00"
时 时]
时 时
是这个 ajax 请求正在收集的 data
数据 , 我如何能够在这个 ajax 函数的成功部分中用它来弹出一个 html 表格 。
$.ajax({
type: "POST",
url: "getJSON.php",
data: submitStr,
success: function (data) {
//populate order details
//loop through variable number of line items
时 时
<html>
<table id="contentTable">
</table>
</html>
还有,