2
I created an app with HTML + JS + CSS , and make an external request with Ajax.
When I test on my computer it works perfectly , but when I pack and create the . APK it gives the following message:
ALERT [object]
How am I supposed to fix this?
Here’s the test code:
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="css/jquery.mobile-1.4.5.min.css">
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.mobile-1.4.5.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery.ajax({
url:"http://comprasemangola.ueuo.com/ver.php",
type:"POST",
dataType:"json",
data: "param=no",
success: function(html){
var DOM =jQuery('#DOM');
console.log(html);
jQuery.each(html,function(key,value){
console.log(value);
DOM.append("
<li><h3>"+value.item+"</h3><p>"+value.quantidade+"</p></li>");
});
},error:function(e){
alert(e);
}
});
});
</script>
</head>
<body>
<div data-role="page">
<div data-role="header" data-theme="b" data-position="fixed">
<h1>Compras em Angola</h1>
<a href="index.php" data-rel="back" data-icon="carat-l" data-iconpos="notext">Back</a>
<a href="#" onclick="window.location.reload()" data-icon="back" data-iconpos="notext">Refresh</a>
</div>
<div style="text-align:center; background-color:#fff; min-height:32px;">
<ul id="DOM"></ul>
</div>
</body>
</html>
see php.
<?php
header('Access-Control-Allow-Origin: *');
$sqlconn=mysqli_connect("","xxxx","texte2015","xxxx") or die(mysqli_error());
$dataquery = mysqli_query($sqlconn, "select * from produtos");
$arr = array();
while ($r=mysqli_fetch_object($dataquery)){
array_push($arr, array("item"=>$r->item, "quantidade"=>$r->quantidade));
# code...
}
print_r(json_encode($arr));
?>
link test http://comprasemangola.ueuo.com/
You would need more information, but by the message you are returning in JSON? Post your code to better understand.
– Roni Sommerfeld