2013-01-10 39 views
0

我試圖在jQuery彈出框中通過Ajax在php myadmin數據庫中傳遞text field。文本以HTML格式編寫,以便自動格式化。 但是,代替文本,正在顯示null。 文本字段:通過Ajax報告從數據庫以HTML格式傳遞文本字段「null」

<div class="topic">Arjun</div> 
<p>content</p><br> 
<div class="clr"></div> 

我沒有提交(或存儲)任何東西。表格(通過其讀取文本)已經手動寫入。

編輯#1

  • 我點擊具有特定的一些id鏈接。
  • id -name被傳遞給一個php腳本並在表中匹配。
  • 詳細信息存儲爲文本字段,並在通過Ajax彈出的jQuery中提取。

這是文本字段之一:

<div class="topic">Arjun</div> 
<p>content</p><br> 
<div class="clr"></div> 

但在jQuery的彈出輸出null

+0

我沒有在你的例子中看到一個textfield - 你忘了粘貼一些更多的代碼? – boz

+0

@boz:請參閱編輯的問題。 – xan

回答

0

什麼是您從phpMyAdmin獲取您的數據?你可以從php文件中獲得它,它實際上從數據庫獲取信息。根據你的職位變動

PHP:

$id=$_POST['id']; 
    $ret = mysql_query("select * from table where id='" . $id . "'"); 
    echo mysql_fetch_array($ret); 
    die(); 

的jQuery:

樣品從你的鏈接

$.ajax({ 
       type: 'POST', 
       url: 'js/db.php', 
       dataType: 'json', 
       data: "id=" + this.id }, 
       success: function(data){ 
        if (data[0]=='showe1'){ 
         $('#' + data).avgrund({ 
          openOnEvent: false, 
          height: 270, 
          width:350, 
          template: '<div class="topic">' + data[1] + '</div>'+ 
          '<div class="clr"></div>'+ 
          '<div class="intro">'+data[2]+'</div>'+ 
          '<div class="clr"></div>'+ 
          '<div>' + 
           '<a href="#" target="_new" class="b2 lfloat">Register</a>' + 
           '<a href="#" target="_new" class="b2 rfloat">More</a>' + 
          '</div>' 
         }); 
        } 

我通過這就像平時看起來這些參數a nd將param從id更改爲data,使其成爲標準配置。這是你需要看到的嗎?

+0

請參閱編輯的問題。 – xan

+0

如何在此處編輯此代碼:http://dpaste.com/871045/ – xan

+0

第10_行中仍然出現_syntax錯誤:http://dpaste.com/871058/ – xan