I am developing an HTML/Javascript/JQuery page retrieving a JSON returned by a PHP script:
$.ajax({
url: "data.php",
dataType: 'json',
success: function(rate) {
var retr = JSON.stringify(rate, null, 2);
$("#data").text(retr);
},
error: function(request,error) {
alert(request.statusText);
}
});
When I view the HTML page from my local PC, the Ajax returns the PHP script code rather than the JSON the PHP code should generate. Somehow, it makes sense since it does not go through a PHP engine.
I have tried replacing url: "data.php" with url: "http://www.mysite.com/data.php" or url: "www.mysite.com/data.php", but it does not work.
I would like to avoid uploading my page on a server to test it. I would like to be able to invoke the PHP on my PHP server directly from my local PC. Is this possible?
<?php ?><?PHPand?>?