全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

IP归属甄别会员请立即修改密码
查看: 1904|回复: 5
打印 上一主题 下一主题

[Windows VPS] AJAX 求助 緊急!!!!!!!!!!!!

[复制链接]
跳转到指定楼层
1#
发表于 2016-6-19 22:17:32 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
300金钱
從Lab08_3a.php 拿資料在Lab08_3a.html的<tbody></tbody> 內顯示結果

Lab08_3a.php
  1. {"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
  1. <html>
  2. <head>
  3. <title>Lab08 Challenge Task</title>
  4. <link rel="stylesheet" href="Lab08_Q3_layout.css"/>
  5. <script src="/jquery/jquery-2.1.4.js"></script>
  6. <script>
  7. $(document).ready( function() {
  8.     (function() {
  9.         $.ajax({
  10.             type: 'POST',
  11.             url: 'http://localhost/lab08/Lab08_3a.php',
  12.             dataType: 'json',
  13.             success: function(result) {
  14.                xxxxxx
  15.             }
  16.         });
  17.     });
  18. });
  19. </script>
  20. </head>
  21. <body>

  22.         <h2>Table of Computer Parts</h2>
  23.         <table id="tableID" border="1">
  24.                 <thead>
  25.                         <tr>
  26.                                 <th>Item</th>
  27.                                 <th>Manufacturer</th>
  28.                                 <th>Model</th>
  29.                                 <th>Cost in $</th>
  30.                         </tr>
  31.                 </thead>
  32.                 <tbody>
  33.                        
  34.                 </tbody>
  35.         </table>
  36. </body>
  37. </html>
复制代码
2#
发表于 2016-6-19 22:17:33 | 只看该作者
  1. $(document).ready( function() {
  2.     (function() {
  3.         $.ajax({
  4.             type: 'POST',
  5.             url: 'http://localhost/lab08/Lab08_3a.php',
  6.             dataType: 'json',
  7.             success: function(result) {
  8.                var part = result.part;

  9.                            var tbody = $('#tableID').find('tbody').eq(0);

  10.                            for(var i in part){
  11.                                         var _p = part[i];
  12.                                         var _html = '<tr><td>'+p.Motherboard+'</td><td>'+p.manufacturer+'</td><td>'+p.model+'</td><td>'+p.cost+'</td></tr>';

  13.                                         $(_html).appendTo(tbody);
  14.                            }
  15.             }
  16.         });
  17.     });
  18. });
复制代码
3#
 楼主| 发表于 2016-6-19 22:30:25 | 只看该作者
4#
 楼主| 发表于 2016-6-19 22:40:02 | 只看该作者

ajax.zip (73.44 KB, 下载次数: 458)

能幫我看下嗎? 金幣給幾多都行 很趕急

5#
发表于 2016-6-19 23:00:14 | 只看该作者
又上新项目了啊
6#
发表于 2016-6-19 23:00:29 | 只看该作者
自己检查一下路径

Lab08_3b.zip

655 Bytes, 下载次数: 507

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2025-9-26 06:41 , Processed in 0.064282 second(s), 11 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表