Webix DataTable view cannot read from PHP function

edited October 2018 in Technical questions

I'm new with "Webix" and I'm trying to build a small app that reads a MySql table and show data in a data table view.

The problem is that the "Webix" view is not reading the JSON code that "get_users.php" is returning. If I run the PHP code only, the JSON screen is correctly echoed on the browser.

If I change the Webix component to read the JSON file directly it works well. What am I doing wrong?

I'm sure that it is a simple issue but I tried a lot and read some articles but the question is still not clear to me.

Here's the HTML Code:

<!DOCTYPE HTML>
<html>
<head>
  <link rel="stylesheet" href="http://cdn.webix.com/edge/webix.css" type="text/css">
  <script src="http://cdn.webix.com/edge/webix.js" type="text/javascript"></script>
</head>
<body>
  <script type="text/javascript" charset="utf-8">

  var layout = webix.ui({
    rows:[
      {template:"row 1", height:50},
      {

        view:"tabview",
        cells:[
          {
            header:"Modalities",
            body:{

              view:"datatable",
              columns:[
                { id:"modalitynumber",    header:"No.",    width:80},
                { id:"modality",   header:"Modality",    width:500},
                { id:"kernel",    header:"Goal",      width:500},
                { id:"active",   header:"A",         width:20}
              ],

              id:"dtable",
              view:"datatable",
              url:"get_users.php"

            }
          },
          {
            header:"Social Systems",
            body:{
              template:"Form Content"
            }
          },
          {
            header:"Identification",
            body:{
              template:"Form Content"
            }
          },
          {
            header:"Systemic Model",
            body:{
              template:"Form Content"
            }
          },

          { header:"Projects",
          body:{
            template:"Some content"
          }
        }
      ]
    }
  ]
});

</script>
</body>
</html>

And here is the PHP code that reads the data and returns a JSON file:

<?php $conn = mysqli_connect("127.0.0.1", "root", "pwd", "mydabase");
if ($conn->connect_error) {
  die("Connection failed: " . $conn->connect_error);
}
$rs = mysqli_query($conn, 'select * from modalities order by modalitynumber');
$result = array();
while($row = mysqli_fetch_object($rs)){
    array_push($result, $row);
}

echo json_encode($result, JSON_UNESCAPED_UNICODE);
$conn->close();
?>
Tagged:

Comments

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion