
- 帖子
- 3
- 主題
- 1
- 精華
- 0
- 積分
- 2
- 威望
- 2
- 金錢
- 0
|
jquery ajax的相關問題
以下是我的程式碼
1 function showDetail(listNum){
2 var stu_id = $("div.listDiv:eq("+listNum+") td:eq(0)").text();
3 $.ajax({
4 type: "POST",
5 url: "ajaxDetail.php",
6 data: "stu_id="+stu_id,
7 success: function(data){
8 alert("success");
9 $("#detail"+listNum).html(data);
10 },
11 error: function(x, a, b){
12 alert(a);
13 }
14 });
15 }
後台
1 <?php
2 if(!isset($_POST['stu_id']))
3 header("Location: http://tw.yahoo.com/");
4 else{
5 $stu_id = $_POST['stu_id'];
6 include_once("mysql.inc.php");
7 $sqlStr = "SELECT name FROM app
8 WHERE stu_id=".$stu_id;
9
10 $result = mysql_query($sqlStr);
11
12 if($result){
13 $row = mysql_fetch_row($result);
14 echo "<table width='100%'>
15 <tr>
16 <th width='30%' scope='row'>姓名</th>
17 <td width='70%'>".$row[0]."</td>
18 </tr>
19 </table>";
20 }else
21 echo "";
22
23
24 }
25 ?>
我已確認傳入的參數正確的
但還是無法成功運作
而測試環境是本機 所以應該不會有權限問題
另外 我的後台檔案在同個目錄下
我試著印出錯誤訊息 他就只給我個"error"...
我實在抓不出錯誤來...
請高手幫忙看看 謝謝 |
|