making jsonp calls and saving it in a sessionStorage
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery.getJSON demo</title>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<script>
var counter = 0;
var timer = setInterval(function(){
var url = "http://api.open-notify.org/iss-now.json?callback=?";
$.getJSON( url, function (data){
// localStorage
sessionStorage.setItem('data', JSON.stringify(data));
counter++;
if(counter > 10){
clearInterval(timer);
}
});
}, 5000);
console.log("Ask for session storage");
var data = sessionStorage.getItem('data');
console.log('data' , data);
</script>
</body>
</html>