Бутстрап-таблица данных-url

Я использую таблицу Bootstrap ( http://wenzhixin.net.cn/p/bootstrap-table/docs/examples.html ), и Im имеет проблемы с привязкой моих данных к таблице с использованием URL-адреса данных.

Вот мой код таблицы:

<table data-toggle="table" data-side-pagination="server" data-url="<? echo $letServiceHandler->getEmployees($_SESSION['api_key'],2); ?>" data-cache="false" data-height="299"> <thead> <tr> <th data-field="id">Item ID</th> <th data-field="name">Item Name</th> <th data-field="price">Item Price</th> </tr> </thead> </table> 

getEmployee вызывает мой rest webservice, который возвращает массив json, который выглядит так:

 [ {"id":"33","name":"5yhjtyjyas 444","active":"0","user_id":"1","no_of_reports":"0"}, {"id":"29","name":"AAA","active":"1","user_id":"1","no_of_reports":"0"}, {"id":"20","name":"aasdasd","active":"1","user_id":"1","no_of_reports":"0"} ] , [ {"id":"33","name":"5yhjtyjyas 444","active":"0","user_id":"1","no_of_reports":"0"}, {"id":"29","name":"AAA","active":"1","user_id":"1","no_of_reports":"0"}, {"id":"20","name":"aasdasd","active":"1","user_id":"1","no_of_reports":"0"} ] 

getEmployee выглядит так:

 // Gets employees public function getEmployees($api_key,$active) { $headers = array('Content-type: application/json','Authorization: '.$api_key,); if($active==0) { $curl = curl_init(GET_ALL_INACTIVE_EMPLOYEES); } else if($active==1) { $curl = curl_init(GET_ALL_ACTIVE_EMPLOYEES); } else { $curl = curl_init(GET_ALL_EMPLOYEES); } curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HTTPGET, true); curl_setopt($curl, CURLOPT_USERPWD, $api_key); $curl_response = curl_exec($curl); if ($curl_response === false) { $info = curl_getinfo($curl); curl_close($curl); die('error occured during curl exec. Additioanl info: ' . var_export($info)); } curl_close($curl); $decoded = json_decode($curl_response,true); return json_encode($decoded['employees']); } 

Обратите внимание, что Im декодирует ответ, а затем снова кодирует его, выбирая только вложенный массив сотрудников.

Я попытался «эхом» json_encode ($ decoded ['employees']) выйти и создать файл данных и поместить его в файл с именем data.json и вставить его в свой URL-адрес. Это сработало отлично ..

После контакта с разработчиком таблицы, я обнаружил, что моя попытка вставить данные в таблицу, установив URL-адрес для моей функции php, не является правильным способом использования этого «свойства».

Мне нужно поместить мою функцию в отдельный файл php, чтобы заставить ее работать, что я сделал, как упоминалось в моем комментарии выше.

Таким образом, решение:

 <table data-toggle="table" data-side-pagination="server" data-url="getEmployees.php?id=2" data-cache="false" data-height="299"> <thead> <tr> <th data-field="id">Item ID</th> <th data-field="name">Item Name</th> <th data-field="price">Item Price</th> </tr> </thead> </table> 

getEmployee.php отправит запрос на мой веб-сервис и вернет результат, который затем будет применен к таблице.