I'm making an application on INTEL XDK, in which I need to connect to the Database. I created PHP to return with JSON and in Intel, I made the function to return such data. But the application is not returning anything, and since I never did anything in this area, I decided to come here to ask for help. Codes:
JSON.PHP
<?php
header("Access-Control-Allow-Origin: *");
header("Content-type: application/json; charset=UTF-8");
$conecta = pg_connect("host=localhost port=5432 dbname=**** user=****** password=******");
$sql = "select * from oi";
$resultado= pg_query($conecta, $sql);
echo '{"produto":}';
$saida = "[";
while($r = pg_fetch_array($resultado))
{
if($saida != "["){$saida.= ", ";}
$saida.= '{"Produto":"'.$r["nomeprod"].'"}';
}
$saida.="}}";
echo $saida;
?>
App.js
$(document).ready(function(){
$.ajax({
type:"GET",
url:"http://200.145.153.172/bruno_pereira/TCC/json.php",
dataType:"json"
}).done(function(data){
var mostra = "";
$.each(data.produto, function(i,x){
mostra+= "<li>"+x.Produto+"</li>";
});
$("#result").html(mostra);
});
});