0

I am making an ajax call on click of anchor tag : There i have a number of arrays as output . But i am unable to display those arrays in an HTML table . Please suggest how can i achieve this .

function getdetail(cid)
{
var cid = cid;
var xmlhttp = new XMLHttpRequest();
var url = "c_detail.php";
var params = "cid="+cid;

xmlhttp.onreadystatechange=function()
  {
    if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {               
            document.getElementById('cdetail').innerHTML = xmlhttp.responseText;        
        }
  }
xmlhttp.open("GET",url+"?"+params,true);
xmlhttp.send();
 }

My array output looks like this : 

Array ( [0] => Array ( [id] => 5088 [start] => first [end] => last [ad_start] =>ad_first [ad_end] => ad_last [cid] => 79 [car] => Dialog ) )

Of-course this shows data as list of arrays without any formatting . I want to display it as HTML table Any help will be appreciated !!! Thanks in advance

4

1 回答 1

2

OK, I advise you to use an existing library like datatables, and you have to convert the php array to json data through json_encode($array) function.

于 2012-09-17T14:13:57.653 回答