我正在開發一個Joomla組件和我使用AJAX對我的看法通過發送GET請求來獲取控制器數據庫表中的內容,然後通過創建模型的數據對象,我打電話給顯示PHP對象我的模型中的一個函數又返回一個JSON對象。
現在我的問題是通過jQuery在html表中顯示該對象的內容。如何使用jQuery
這裏是我的代碼:
jQuery("#papertitle").change(function(){
console.log('eneterd jquery function');
var title =jQuery('#papertitle').val();
jQuery.ajax({
type: 'GET',
url: "http://localhost/joomladev/index.php?option=com_journals&task=payments&format=raw&title="+title,
data: {title : title},
success: function(data){
console.log('data',data);
jQuery('#data-table').html(data);
}
});
});
在數據表是我的股利。而且它顯示JSON對象作爲輸出是這樣的:
array (size=1)
0 =>
object(stdClass)[165]
public 'paperid' => string '4' (length=1)
public 'journalid' => string '7' (length=1)
public 'papertitle' => string 'Big Data' (length=8)
public 'classification' => string 'computer science' (length=16)
public 'status' => string 'complete' (length=8)
public 'comments' => string 'none' (length=4)
但我想以表格的形式來顯示物體的細節。 關於如何使用jQuery來做任何建議!
它worked..thanks試試這個! :) –