全球主机交流论坛
标题:
AJAX 求助 緊急!!!!!!!!!!!!
[打印本页]
作者:
CloudLink.asia
时间:
2016-6-19 22:17
标题:
AJAX 求助 緊急!!!!!!!!!!!!
從Lab08_3a.php 拿資料在Lab08_3a.html的<tbody></tbody> 內顯示結果
Lab08_3a.php
{"part":[{"item":"Motherboard","manufacturer":"ASUS","model":"P3B-F","cost":" 123.00"},{"item":"Video Card","manufacturer":"ATI","model":"All-in-Wonder Pro","cost":" 160.00"},{"item":"Sound Card","manufacturer":"Creative Labs","model":"Sound Blaster Live","cost":" 80.00"},{"item":" inch Monitor","manufacturer":"LG Electronics","model":" 995E","cost":" 290.00"}]}
复制代码
Lab08_3a.html
<html>
<head>
<title>Lab08 Challenge Task</title>
<link rel="stylesheet" href="Lab08_Q3_layout.css"/>
<script src="/jquery/jquery-2.1.4.js"></script>
<script>
$(document).ready( function() {
(function() {
$.ajax({
type: 'POST',
url: 'http://localhost/lab08/Lab08_3a.php',
dataType: 'json',
success: function(result) {
xxxxxx
}
});
});
});
</script>
</head>
<body>
<h2>Table of Computer Parts</h2>
<table id="tableID" border="1">
<thead>
<tr>
<th>Item</th>
<th>Manufacturer</th>
<th>Model</th>
<th>Cost in $</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</body>
</html>
复制代码
作者:
psdshow
时间:
2016-6-19 22:17
$(document).ready( function() {
(function() {
$.ajax({
type: 'POST',
url: 'http://localhost/lab08/Lab08_3a.php',
dataType: 'json',
success: function(result) {
var part = result.part;
var tbody = $('#tableID').find('tbody').eq(0);
for(var i in part){
var _p = part[i];
var _html = '<tr><td>'+p.Motherboard+'</td><td>'+p.manufacturer+'</td><td>'+p.model+'</td><td>'+p.cost+'</td></tr>';
$(_html).appendTo(tbody);
}
}
});
});
});
复制代码
作者:
CloudLink.asia
时间:
2016-6-19 22:30
psdshow 发表于 2016-6-19 22:22
還是不行
作者:
CloudLink.asia
时间:
2016-6-19 22:40
psdshow 发表于 2016-6-19 22:22
(, 下载次数: 459)
上传
点击文件名下载附件
能幫我看下嗎? 金幣給幾多都行 很趕急
作者:
gger
时间:
2016-6-19 23:00
又上新项目了啊
作者:
psdshow
时间:
2016-6-19 23:00
自己检查一下路径
欢迎光临 全球主机交流论坛 (https://443502.xyz/)
Powered by Discuz! X3.4