How to fetch the data from the php using json in phonegap, On server xampp, I just write the following code replay.php. I have taken these example from this line and and I want to mention this question from stackover flow, try to make according to it but my android emulator is not resounding, please help me on this topic, I am new in phonegap and android,
replay.php
<?php
header('Content-Type: application/json');
$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);
?>
In eclipse I write the following code in index.html
<!DOCTYPE html>
<html>
<head>
<script charset="utf−8" type="text/javascript">
function connect(e)
{
var term= {button:e};
$.ajax({
url:'http://localhost/Experiements/webservices/reply.php',
type:'POST',
data:term,
dataType:'json',
error:function(jqXHR,text_status,strError){
alert("no connection");},
timeout:60000,
success:function(data){
$("#result").html("");
for(var i in data){
$("#result").append("<li>"+data[i]+"</li>");
}
}
});
}
</script>
</head>
<body>
<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>