I keep getting this error when trying to retrieve and display information in my phonegap application.
This is the error I get:
GET http://192.168.0.4:3000/Application/www/retrieveSymbol.php send @ jquery-2.2.0.js:9172jQuery.extend.ajax @ jquery-2.2.0.js:8653jQuery.(anonymous function) @ jquery-2.2.0.js:8804jQuery.extend.getJSON @ jquery-2.2.0.js:8785(anonymous function) @ bookmarks.html:44 bookmarks.html:1 XMLHttpRequest cannot load http://192.168.0.4:3000/Application/www/retrieveSymbol.php. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. The response had HTTP status code 404.
This is the code:
<script>
//populates product container
$(" #productContainer").html('');
$.getJSON("http://192.168.0.4:3000/Application/www/retrieveSymbol.php", function(data){ //retrieves json array
$.each(data, function(i, field){ //loops through array
$("#productContainer").append( //creates product box filling it with data
"<div id='productBox'>" + "<div id='name'>" + field[1] + " </div>" + "<br>" +
"<div id='image'>" + "<img id='image' src='Images/" + field[5] + "'/>" + "</div>" +
"<div id='description'>" + "<b>Description:</b> " + "<br>" + field[2] + " </div>" + "" +
"<div id='price'>" + "£" + field[3] + " </div>" + "<br><br>" + "<br>" +
//gets name and price and sends data to basket when button is clicked
"<form action='Basket.php' method='post' id='add'>" +
"<input type='hidden' name='itemName' value=" + field[1] + "/>" +
"<input type='hidden' name='itemPrice' value=" + field[3] + ">" +
"<input id='addButton'type='submit' value='Add to Cart'>" +
"</form>" + "</div>"
);
});
});
</script>
recieveSymbol.php
<?php
//connect to the database
$mysqli = NEW MySQLi ('localhost','root','','contentdatabase');
//query database
$resultSet = $mysqli->query("SELECT * FROM items");
//count the rows
if($resultSet->num_rows != 0) {
//turn the results into an array
$rows = $resultSet->fetch_all();
echo json_encode($rows);
}else{
echo "{no connection}";
}
?>
Can anyone point out why this is happening?