You need to query your data from a database or from somewhere else in PHP. Then, you can echo
it with PHP in a JSON format. In a second step, you can use jQuery or plain JavaScript to make an Ajax call to this PHP file and make something with it.
PHP (data.json.php):
<?php
header('Content-Type: application/json');
$output = array();
// query the data from somewhere
$output['data'] = "1234";
echo json_encode($output); // json_encode creates the json-specific formatting
?>
JavaScript (jQuery):
$.ajax({
url: "data.json.php",
success: function(result){
console.log(result);
}
});
The code is untested, but I think you should get the idea.
url
parameter which is available./your-file.php
which is located onhttp://localhost/
.. the full path might be something likehttp://localhost/your-file.php
and as @Ahamed posted, make sure you have a web server running otherwise what I said is not possible.