Web / Cordova / Phonegap Mobile App (Javascript)
function loadData() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
// do something with 'this.responseText'
}
};
xhttp.open("GET", "http://yourUrlHere/json.php?secret=yourSecretHere", true);
xhttp.send();
}
Web / Cordova / Phonegap Mobile App (jQuery)
$.get("http://yourUrlHere/json.php?secret=yourSecretHere", function(data, status) {
// do something with 'data'
});
Web / Mobile (Ionic 1) (AngularJS 1)
$http.get("http://yourUrlHere/json.php?secret=yourSecretHere")
.then(function(response) {
// do something with 'response.data'
});
Web / Mobile (Ionic 2/3) (AngularJS 2/3)
constructor(public navCtrl: NavController, public http: Http) {
this.http.get('http://yourUrlHere/json.php?secret=yourSecretHere').map(res => res.json()).subscribe(data => {
// do something with 'data'
});
}