Replace
<access origin=".*"/>
with
<access origin="*"/>
Maybe it will solve a problem.
Pergunta
i have a problem with the phonegap app.
I try to connect with ajax post with simple php file which return my an array in my app. This is simple example/tutorial from net. I try everything i read a tousends of topics, but i don't know where is problem.
My index of the phonegap app
<html>
<head>
<meta name="viewport" content="width=320; user-scalable=no" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Minimal AppLaud App</title>
<script type="text/javascript" charset="utf-8" src="cordova-1.9.0.js"></script>
<script type="text/javascript" charset="utf-8">
function connect(e)
{
var term= {button:e};
$.ajax({
url:'http://domain.pl/replay.php',
type:'POST',
data:term,
dataType:'json',
error:function(jqXHR,text_status,strError){
alert('no connection');},
timeout:6000,
success:function(data){
$("#result").html("");
for(var i in data){
$("#result").append("<li>"+data[i]+"</li>");
}
}
});}
</script>
</head>
<body id="stage" class="theme">
<center><b>Bikes or Cars</b></center>
<center><input onclick="connect(this.value)" type="button" value="cars" /></center>
<center><input onclick="connect(this.value)" type="button" value="bikes" /></center>
<center><b>Results</b></center>
<ul id="result"></ul>
</body>
</html>
And my replay.php file
<?php
$choice =$_POST["button"];
$cars = array("Honde", "BMW" , "Ferrari");
$bikes = array("Ducaite", "Royal Enfield" , "Harley Davidson");
if($choice == "cars") print json_encode($cars);
else print json_encode($bikes);
?>
I add domain whitelist to cordova and config xml files
<access origin=".*"/>
And i don't have any ideas what is wrong. Thanks in advance for any suggestions.
Solução
Replace
<access origin=".*"/>
with
<access origin="*"/>
Maybe it will solve a problem.