recentpopularlog in

alexpotato : javascript   69

Track Google Analytics Events  |  Analytics for Web (gtag.js)  |  Google Developers
gtag('event', <action>, {
'event_category': <category>,
'event_label': <label>,
'value': <value>
});
google  analytics  scrolltracking  gtag  javascript  example  howto  help 
april 2018 by alexpotato
Loading JSON-formatted data with Ajax and xhr.responseType='json' · Mathias Bynens
var getJSON = function(url, successHandler, errorHandler) {
var xhr = new XMLHttpRequest();
xhr.open('get', url, true);
xhr.responseType = 'json';
xhr.onload = function() {
var status = xhr.status;
if (status == 200) {
successHandler && successHandler(xhr.response);
} else {
errorHandler && errorHandler(status);
}
};
xhr.send();
};

getJSON('https://mathiasbynens.be/demo/ip', function(data) {
alert('Your public IP address is: ' + data.ip);
}, function(status) {
alert('Something went wrong.');
});
javascript  json  ajax 
march 2017 by alexpotato

Copy this bookmark:





to read