[Solved] How to download silently with javascript


Regarding silent part

Your browser is always aware of the network requests which are made from JS. Therefore, the user can always see all the requests and responses by opening developer tools.


Now coming to loading a remote json to the memory in the client

Since you mentioned you are relatively a newbie in JS, I am going to cover the very basic, so please bear with me if you already know it

You need to make an ajax call using an XMLHttpRequest as shown here


However, most people use some library like jQuery while working to abstract checking state of the request and other trivial tasks. This results in making an ajax call as simple as calling a method and providing a callback method to process the response.

$.ajax({
  url: '/path/to/file',
  type: 'default GET (Other values: POST)',
  dataType: 'default: Intelligent Guess (Other values: xml, json, script, or html)',
  data: {param1: 'value1'},
})
.done(function() {
  console.log("success");
})
.fail(function() {
  console.log("error");
})
.always(function() {
  console.log("complete");
});

You may find the example at below link.

http://api.jquery.com/jquery.getjson/

P.S.: Due the less reputation points, I can neither post any supporting images nor more than two links.

1

solved How to download silently with javascript