I am trying to run the jtable demos for php, but am always having an error that is :
"An error occured while communicating to the server".
I know that i can list the json encode , because i tried to print it, but cant get the data inside the table because of that error.
Thanks in advance
index.html:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Datatable with mysql</title>
<link href="themes/redmond/jquery-ui-1.8.16.custom.css" rel="stylesheet" type="text/css" />
<link href="Scripts/jtable/themes/lightcolor/blue/jtable.css" rel="stylesheet" type="text/css" />
<script src="scripts/jquery-1.6.4.min.js" type="text/javascript"></script>
<script src="scripts/jquery-ui-1.8.16.custom.min.js" type="text/javascript"></script>
<script src="Scripts/jtable/jquery.jtable.js" type="text/javascript"></script>
<div class="container">
<div class="">
<h1>jTable Demo Server Side</h1>
<div class="col-sm-8" id="employee_grid">
</div>
</div>
</div>
<script type="text/javascript">
$( document ).ready(function() {
$('#employee_grid').jtable({
title: 'List of Employees',
defaultSorting: 'Name ASC',
actions: {
listAction: 'response.php?action=list',
createAction: 'response.php?action=create',
updateAction: 'response.php?action=update',
deleteAction: 'response.php?action=delete'
},
fields: {
personID: {
title: 'EMPId',
width: '10%',
edit: false
},
name: {
title: 'Employee Name',
width: '40%'
},
age: {
title: 'Employee Salary',
width: '20%'
},
recordDate: {
title: 'Age',
width: '30%'
}
}
});
$('#employee_grid').jtable('load');
});
</script>
response.php
<?php
try
{
//Open database connection
$con = mysqli_connect('localhost', 'root', '','aaa') or die("Connection failed: " . mysqli_connect_error());
mysqli_select_db( $con,"aaa");
//Getting records (listAction)
if($_REQUEST["action"] == "list")
{
//Get records from database
$result = mysqli_query($con,"SELECT * FROM `people`;");
//Add all records to an array
$rows = array();
while($row = mysqli_fetch_array($result))
{
$rows[] = $row;
}
//Return result to jTable
$jTableResult = array();
$jTableResult['Result'] = "OK";
$jTableResult['Records'] = $rows;
echo json_encode($jTableResult);
}
else if($_REQUEST["action"] == "create")
{
//Insert record into database
$result = mysqli_query($con, "INSERT INTO people(Name, Age, RecordDate) VALUES('" . $_POST["Name"] . "', " . $_POST["Age"] . ",now());");
//Get last inserted record (to return to jTable)
$result = mysqli_query($con , "SELECT * FROM people WHERE PersonId = LAST_INSERT_ID();");
$row = mysqli_fetch_array($result);
//Return result to jTable
$jTableResult = array();
$jTableResult['Result'] = "OK";
$jTableResult['Record'] = $row;
print json_encode($jTableResult);
}
//Creating a new record (createAction)
//Close database connection
mysqli_close($con);
}
catch(Exception $ex)
{
//Return error message
$jTableResult = array();
$jTableResult['Result'] = "ERROR";
$jTableResult['Message'] = $ex->getMessage();
echo json_encode($jTableResult);
}
?>
That is I cant put this demo to work.
Related
I have PHP program to pull data from a MS SQL Server and encode the result in JSON
Here is the code below ->
<?php
/*
connect to MS SQL Server using PHP
*/
$serverName = "192.168.0.4,14333"; // ip:port
$connectionInfo = array( "Database"=>"YYY", "UID"=>"XX", "PWD"=>'XX');
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn ) {
echo "Connection established.<br />";
}else{
echo "Connection could not be established.<br /><pre>";
die( print_r( sqlsrv_errors(), true));
}
$tsql = "
SELECT * FROM projections_sample
";
$getResults= sqlsrv_query($conn, $tsql);
echo ("Reading data from table" . PHP_EOL);
if ($getResults == FALSE)
die(FormatErrors(sqlsrv_errors()));
$rows1 = array();
$rows1['name'] = 'Revenue';
while ($r1 = sqlsrv_fetch_array($getResults, SQLSRV_FETCH_ASSOC))
{
$rows1['data'][] = $r1['revenue'];
}
$getResults= sqlsrv_query($conn, $tsql);
echo ("Reading data from table" . PHP_EOL);
if ($getResults == FALSE)
die(FormatErrors(sqlsrv_errors()));
$rows2 = array();
$rows2['name'] = 'Overhead';
while ($r2 = sqlsrv_fetch_array($getResults, SQLSRV_FETCH_ASSOC))
{
$rows2['data'][] = $r2['overhead'];
}
sqlsrv_free_stmt($getResults);
$result = array();
array_push($result,$rows1);
array_push($result,$rows2);
echo json_encode($result, JSON_NUMERIC_CHECK);
sqlsrv_close($conn);
?>
The results seem to be okay(I pasted the results into a JSON file (data.JSON) and pulled the results into highcharts)
The JSON results are not being pulled when the following code is used -
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Dynamic Chart</title>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
<div id="container" style="min-width: 155px; height: 500px; margin: 0 auto"></div>
<script>
let titleText = ' Revenue Vs Overhead'
let categoryLabels = ['Jan','Feb','Mar','Apr','May',Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
let yAxisText = 'Delta';
$(document).ready(function(){
$.ajax({
datatype: "json",
url: "data.php",
success: function(result)
{
Highcharts.chart('container', {
chart: {
type: 'line'
},
credits: {
enabled: false
},
title: {
text: titleText
},
xAxis: {
categories: categoryLabels
},
yAxis: {
min: 0,
title: {
text: yAxisText
}
},
series: result
});
},
error: function(xhr, desc, err) {
console.log(xhr);
console.log("Details: " + desc + "\nError:" + err);
}
}); //End Ajax Call
});
</script>
</body>
</html>
When I run the code I get a blank web page.
I can't seem to get my button to work. the button will update mysql values when it is pressed. however, when i press the button, nothing happen. no logs appear on the console. did i miss something here?
the plan is to have a graph at the top and a table just below the graph. the graph will serve as a live graph.
the value in the table will toggle between on/off to simulate control of a water pump.
index2_2.php
<?php
require 'mysql.php';
?>
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" media="screen" href="style.css" />
<!-- jQuery Script -->
<script
src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
crossorigin="anonymous">
</script>
<script>
// jQuery code
// jQuery code available after the page has fully loaded
$(".table #tbody1").on('click', ':button', function(){
id = $(this).prop("id");
console.log('button ' + id + ' pressed');
if($(this).prop('value') == 'ON'){
status = 'OFF';
}else{
status = 'ON';
}
// load table with updated values
$('#tbody1').load("mysql.php", {
id: id,
status: status
}, function(){
console.log('table loaded');
});
});
</script>
<script>
window.onload = function() {
var updateInterval = 2000;
var sensor1Data = [];
var sensor2Data = [];
var chart = new CanvasJS.Chart("chartContainer", {
zoomEnabled: true,
title: {
text: "Soil Moisture Reading"
},
axisX: {
title: "chart updates every " + updateInterval / 1000 + " secs"
},
axisY:{
includeZero: false
},
toolTip: {
shared: true
},
legend: {
cursor:"pointer",
verticalAlign: "top",
fontSize: 22,
fontColor: "dimGrey",
itemclick : toggleDataSeries
},
data: [{
type: "line",
name: "Sensor 1",
dataPoints: sensor1Data
},
{
type: "line",
name: "Sensor 2",
dataPoints: sensor2Data
}]
});
setInterval(function(){updateChart()}, updateInterval);
function toggleDataSeries(e) {
if (typeof(e.dataSeries.visible) === "undefined" || e.dataSeries.visible) {
e.dataSeries.visible = false;
}
else {
e.dataSeries.visible = true;
}
chart.render();
}
function updateChart() {
$.getJSON("http://192.168.1.3/Socket-4/getsensor.php", addData);
}
function addData(data){
// try using ID to filter new values.
// eg: newData[i].ID != oldData[i].ID
// only plot new data. shift graph when datapoints > than a value
for (var i = 0; i < data.length; i++) {
if(data[i].sensorName == 'sensor 1'){
sensor1Data.push({
x: new Date(data[i].Date),
y: Number(data[i].sensorValue)
});
}
if(data[i].sensorName == 'sensor 2'){
sensor2Data.push({
x: new Date(data[i].Date),
y: Number(data[i].sensorValue)
});
}
}
chart.render();
}
$.getJSON("http://192.168.1.3/Socket-4/getsensor.php", addData);
}
</script>
</head>
<body>
<div id="chartContainer" style="height: 370px; width: 100%;"></div>
<script src="https://canvasjs.com/assets/script/jquery-1.11.1.min.js"></script>
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<div class="table">
<table>
<thead>
<tr>
<th>ID:</th>
<th>Name:</th>
<th>Status:</th>
</tr>
</thead>
<tbody id='tbody1'>
<?php
getValues();
?>
</tbody>
</table>
</div>
</body>
</html>
mysql.php
<?php
require_once 'mysqldb.php';
include 'socket.php';
if(isset($_POST['id']) and isset($_POST['status'])){
$id = $_POST['id'];
$status = $_POST['status'];
updateValues($id, $status);
getValues();
}
function getValues(){
/*
This function retrieves the values from the database
and store it in an array.
*/
global $db_host, $db_user, $db_pass, $db_name;
$data = array();
/* start connection */
$conn = mysqli_connect($db_host, $db_user, $db_pass, $db_name);
/* check connection */
if (mysqli_connect_errno()) {
printf("Connection failed: %s\n", mysqli_connect_error());
exit();
}
$sql = 'SELECT * FROM actuator ORDER BY ID';
if($query = mysqli_query($conn,$sql)){
while($row = mysqli_fetch_array($query, MYSQLI_ASSOC)){
$data[] = $row;
// Display into html table
echo "<tr>";
echo "<td>{$row['ID']}</td>";
echo "<td>{$row['name']}</td>";
echo "<td>
<input type='button' id='{$row['ID']}' value='{$row['value']}' name='{$row['name']}'>
</td>";
echo "</tr>";
}
/* free result set */
mysqli_free_result($query);
}
/* close connection */
mysqli_close($conn);
socket($data);
}
function updateValues($id, $status){
/*
This function updates the database with
values retrieved from POST.
*/
global $db_host, $db_user, $db_pass, $db_name;
/* start connection */
$conn = mysqli_connect($db_host, $db_user, $db_pass, $db_name);
/* check connection */
if (mysqli_connect_errno()) {
printf("Connection failed: %s\n", mysqli_connect_error());
exit();
}
// Prevent SQL injection
$status = mysqli_real_escape_string($conn, $status);
$id = mysqli_real_escape_string($conn, $id);
// $sql = "UPDATE actuator SET value='$status' WHERE ID=$id";
$sql = "INSERT INTO led_control (ID, value, name) VALUES ('$id', '$status', 'water pump')";
mysqli_query($conn,$sql);
/* close connection */
mysqli_close($conn);
}
?>
maybe the event handler
$(".table #tbody1").on('click', ':button', function(){
is called before the button is rendered.
Put the Handler inside of
$( document ).ready(function() {
like
<script>
$( document ).ready(function() {
// jQuery code
// jQuery code available after the page has fully loaded
$(".table #tbody1").on('click', ':button', function(){
id = $(this).prop("id");
console.log('button ' + id + ' pressed');
if($(this).prop('value') == 'ON'){
status = 'OFF';
}else{
status = 'ON';
}
// load table with updated values
$('#tbody1').load("mysql.php", {
id: id,
status: status
}, function(){
console.log('table loaded');
});
});
});
</script>
you can change echo like
echo "<td>
<input type='button' id='{$row['ID']}' value='{$row['value']}' name='{$row['name']}' onClick=test({$row['ID']})>
</td>";
and script:
function test(index){
....
}
or
echo "<td>
<input class = 'nameofclass' type='button' id='{$row['ID']}' value='{$row['value']}' name='{$row['name']}' onClick=test({$row['ID']})>
</td>";
$('table#tbody1').on('click','button.nameofclass',function(e) {
I have a very basic HTML Table. The data is from the database. I have now set up a datepicker with a button and as soon I click the button I do a AJAX request to get specific data for a specific date. (To make it easier my query just looks for id=1 as an example). I now want to return the data abnd update the datatable, but unfortunately the data is returned, but not shown.
data […]
0 {…}
id 1
category_id 1
title Technology Post One
This above is what gets returned. Am I doing a mistake in the format of the above or how do I update the datatable? I get the following error:
DataTables warning: table id=example - Requested unknown parameter '0' for row 0, column 0
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "api_db";
if(isset($_SERVER['HTTP_X_REQUESTED_WITH'])
&& !empty($_SERVER['HTTP_X_REQUESTED_WITH'])
&& strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
{
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM posts WHERE id = 1";
result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$rows[] = $row;
}
} else {
echo "0 results";
}
$conn->close();
$msg = ["data" => $rows];
// handle request as AJAX
echo json_encode($msg);
exit;
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Practise</title>
<link href="https://cdn.datatables.net/1.10.20/css/jquery.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.20/css/jquery.dataTables.css">
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.20 js/jquery.dataTables.js"></script>
</head>
<body>
<?php
$sql = "SELECT * FROM posts";
$result = $conn->query($sql);
while($row = $result->fetch_assoc()) {
$rows[] = $row;
}
$conn->close();
?>
<table id="example" border="1"><thead>
<th>id</th>
<th>title</th>
<th>created at
<p>Date: <input type="text" id="datepicker"><button>Click</button> </p>
</th>
</thead>
<?php
foreach ($rows as $value){
echo '<tr>';
echo '<td>'.$value['id'].'</td>';
echo '<td>'.$value['title'].'</td>';
echo '<td>'.$value['created_at'].'</td>';
echo '</tr>';
}
echo '</table>'
?>
</body>
<script>
$(document).ready(function() {
$('#example').DataTable({
"columns": [
{"data": "id"},
{"data": "author"},
{"data": "created_at"}
],
},
);
$( "#datepicker" ).datepicker();
$("button").click(function(e) {
e.preventDefault();
$.ajax({
type: "POST",
data: {
created_at: $("#datepicker").val()
},
success: function(data) {
$('#example').DataTable().ajax.reload();
},
error: function(result) {
alert('error');
}
});
});
} );
You can update the js script and create a new php file for ajax call which will return the new datatable. Try out this code it will work -
<script>
var created_at = '';
$(document).ready(function() {
var datatable = $('#example').DataTable({
'processing': true,
'scrollX': true,
'serverSide': true,
'serverMethod': 'post',
'searching' : true,
'ajax': {
url:'new-file.php',
data: function(data){
data.created_at = created_at;
}
},
"columns": [
{"data": "id"},
{"data": "author"},
{"data": "created_at"}
],
});
$( "#datepicker" ).datepicker();
$("button").click(function(e) {
e.preventDefault();
created_at = $("#datepicker").val();
datatable.draw();
});
} );
</script>
Hello guys i am new to both ajax and JSON and i have followed this guide on making a jquery slider and getting some result from DB it is working but right now i can only get one result from the slider range but i want to get all results from that range so i need to pass more then one result variable from my php and cant seem to get it to work i have included my code below
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"></script>
<script src="slider.js"></script>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<div>
<span id="deal_min_price"></span>
<span id="deal_max_price" style="float: right"></span>
<br /><br />
<div id="slider_price"></div>
<br />
<span id="number_results"></span> Abonnementer fundet
</div>
</body>
</html>
$(document).ready(function()
{
$( "#slider_price" ).slider({
range: true,
min: 0,
max: 349,
step:1,
values: [ 0, 349 ],
slide: function( event, ui ) {
$( "#deal_min_price" ).text(ui.values[0] + "KR");
$( "#deal_max_price" ).text(ui.values[1] + "KR");
},
stop: function( event, ui ) {
var dealsTotal = getDeals(ui.values[0], ui.values[1]);
$("#number_results").text(dealsTotal);
},
});
$("#deal_min_price").text( $("#slider_price").slider("values", 0) + "KR");
$("#deal_max_price").text( $("#slider_price").slider("values", 1) + "KR");
});
function getDeals(min_price, max_price)
{
var numberOfDeals = 0;
$.ajax(
{
type: "POST",
url: 'deals.php',
dataType: 'json',
data: {'minprice': min_price, 'maxprice':max_price},
async: false,
success: function(data)
{
numberOfDeals = data;
}
});
return numberOfDeals;
}
PHP:
<?php
$result = 0;
define('MYSQL_HOST', 'db564596075.db.1and1.com');
define('MYSQL_USER', 'dbo564596075');
define('MYSQL_PASSWORD', '12345678');
define('MYSQL_DB', 'db564596075');
try
{
$dbh = new PDO('mysql:host='.MYSQL_HOST.';dbname='.MYSQL_DB, MYSQL_USER, MYSQL_PASSWORD);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dbh->setAttribute(PDO::ATTR_PERSISTENT, true);
$dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
$dbh->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
}
catch (PDOException $e)
{
echo 'Fejk: ' . $e->getMessage() . '<br/>';
}
if(isset($_POST['minprice']) && isset($_POST['maxprice']))
{
$minprice = filter_var($_POST['minprice'] , FILTER_VALIDATE_INT);
$maxprice = filter_var($_POST['maxprice'] , FILTER_VALIDATE_INT);
$query = '
SELECT
*
FROM
mobilabonnement
WHERE
Prisprmdr
BETWEEN
:minprice
AND
:maxprice
';
$stmt = $dbh->prepare($query);
try
{
$stmt->bindParam(':minprice', $minprice);
$stmt->bindParam(':maxprice', $maxprice);
$stmt->execute();
}
catch (PDOException $e)
{
print($e->getMessage());
die;
}
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$result = $row['Selskab'];
}
if ($result == true)
{
echo json_encode($result);
}
else{
echo json_encode(0);
}
?>
Here is why You got only Selskab - $result = $row['Selskab'];
Try that:
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$result = $row;
if ($result)
{
echo json_encode($result);
}
else
{
echo json_encode(0);
}
You need to loop over all the results or use PDO::fetchAll, if you want all the columns you also need to use the whole row not just Selskab:
$result = array();
while (false !== ($row = $stmt->fetch(PDO::FETCH_ASSOC))) {
$result[] = $row;
}
if (count($result)
{
echo json_encode($result);
} else{
echo json_encode(0);
}
OR using PDO::fetchAll:
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
if (count($result)
{
echo json_encode($result);
} else{
echo json_encode(0);
}
However it also seems you really only want Selskab and id as opposed to all of the columns and in that case you should probably adjust your query as well:
SELECT id, Selskab
FROM mobilabonnement
WHERE Prisprmdr BETWEEN :minprice AND :maxprice
I generated some Json data from Mysql Database with PHP as below:
equipments.php
<?php
require("config.inc.php");
//initial query
$query = "Select * FROM equipment";
//execute query
try {
$stmt = $db->prepare($query);
$result = $stmt->execute($query_params);
}
catch (PDOException $ex) {
$response["success"] = 0;
$response["message"] = "Database Error!";
die(json_encode($response));
}
// Finally, we can retrieve all of the found rows into an array using fetchAll
$rows = $stmt->fetchAll();
if ($rows) {
$response["success"] = 1;
$response["message"] = "Equipment Available!";
$response["equipments"] = array();
foreach ($rows as $row) {
$post = array();
$post["EquipmentId"] = $row["EquipmentId"];
$post["Name"] = $row["Name"];
$post["Ip"] = $row["Ip"];
$post["Brand"] = $row["Brand"];
$post["Location"] = $row["Location"];
//update our repsonse JSON data
array_push($response["equipments"], $post);
}
// echoing JSON response
echo json_encode($response);
} else {
$response["success"] = 0;
$response["message"] = "No Equipment Available!";
die(json_encode($response));
}
?>
this returned the following data:
//localhost/equip/equipments.php (on my local apache server)
{
success: 1,
message: "Equipment Available!",
equipments: [
{
EquipmentId: "1",
Name: "UCH-NET",
Ip: "172.16.32.4",
Brand: "Engenius",
Location: "Top of ITD"
},
{
EquipmentId: "2",
Name: "UCH-PHOUSE",
Ip: "172.16.32.5",
Brand: "Mikrotik",
Location: "Top of ITD"
},
{
EquipmentId: "3",
Name: "UCH-SON",
Ip: "172.16.32.9",
Brand: "MIkrotik",
Location: "SON"
},
{
EquipmentId: "4",
Name: "UCH-GERIATRIC",
Ip: "172.16.32.10",
Brand: "Mikrotik",
Location: "Geriatric"
}
]
}
But when i try to use the returned Json like this in my AngularJS application no data is returned in the web page
services.js
'use strict';
var equipServices = angular.module('equipServices', ['ngResource']);
equipServices.factory('Equip', ['$resource',
function($resource){
return $resource( '/equip/equipments.php/');
}]);
equipment.js
function EquipmentsCtrl ($scope, Equip) {
$scope.setActive('equipments');
$scope.sidebarURL = 'partials/equipment.html';
$scope.currentEquipment = null;
$scope.setEquipment = function (EquipmentId) {
$scope.currentEquipment = $scope.equipments[EquipmentId];
};
$scope.equipments = Equip.query();
}
}
index.html
<title>IP Library</title>
<script type="text/javascript" src="js/lib/angular.min.js"></script>
<script type="text/javascript" src="js/lib/angular-resource.min.js"></script>
<script type="text/javascript" src="js/controllers/app.js"></script>
<script type="text/javascript" src="js/controllers/equipments.js"></script>
<script type="text/javascript" src="js/controllers/admins.js"></script>
<script type="text/javascript" src="js/app.js"></script>
<script type="text/javascript" src="js/services.js"></script>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/bootstrap-responsive.min.css">
</head>
<body>
<div class="container" ng-controller="AppCtrl" >
<h1>IP Library</h1>
<ul class="nav nav-pills">
<li ng-class="equipmentsActive">
<a href="#equipments" >Equipments</a>
</li>
<li ng-class="adminsActive">
Administrators
</li>
</ul>
<div ng-view></div>
</div>
</body>
</html>
Is there something wrong with the way I am calling the php generated Json in my services.js?
Thanks
Use Equip.get() instead of Equip.query() because you are getting from server an object, not an array:
Equip.get(function(result){
if(result.success === 1) // isn't better to return boolean?
$scope.equipments = result.equipments;
// else handle error
});