-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAsyncGet.js
More file actions
28 lines (26 loc) · 837 Bytes
/
AsyncGet.js
File metadata and controls
28 lines (26 loc) · 837 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*
Code from tggagne on http://stackoverflow.com/questions/247483/http-get-request-in-javascript
Modified by: Sludovic - 2014-12-18
*/
/* "tag" string for multiple call a the same time. Dont use same text */
var HttpClient = function() {
this.get = function(aUrl, aCallback,tag) {
var anHttpRequest = 'anHttpRequest'.tag;
anHttpRequest = new XMLHttpRequest();
anHttpRequest.onreadystatechange = function() {
if (anHttpRequest.readyState == 4 && anHttpRequest.status == 200)
aCallback(anHttpRequest.responseText);
}
anHttpRequest.open( "GET", aUrl, true );
anHttpRequest.send( null );
}
}
aClient = new HttpClient();
aClient.get(
'http://url/get.php?any=value',
function(answer) {
var graphInscrit = document.getElementById('IDELEMENT');
graphInscrit.innerHTML = answer;
},
"TAG"
);