{"action":"created","comment":{"url":"https://api.github.com/repos/blank-4/exercises-yassinezb/pulls/comments/240234692","pull_request_review_id":183215728,"id":240234692,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0MDIzNDY5Mg==","diff_hunk":"@@ -0,0 +1,54 @@\n+/* # Le traitement des requetes AJAX\n+\n+## Construisons d'abord notre mini serveur\n+\n+Pour effectuer une requete AJAX, on a besoin d'un serveur. En effet, les navigateurs nous interdisent de faire des requetes entre fichiers statiques et serveurs.\n+\n+* Placez vous dans le dossier de votre exercice à l'aide du terminal. Rappel : Pour se déplacer dans un dossier, utilisez la commande `cd`\n+* Vérifiez que vous etes dans le bon dossier avec la commande `pwd`\n+* Créez un fichier `index.html`\n+* Démarrez votre serveur avec la commande : `python -m SimpleHTTPServer`\n+* Vérifiez que votre serveur est accessible à l'adresse suivante : `http://localhost:8000`\n+\n+## Téléchargeons les données\n+\n+Pour effectuer une requete AJAX, on a besoin de données !\n+* Créez un fichier `data.json` dans le dossier de votre projet\n+* Mettez y le texte que vous trouverez ici : [http://blank.bellevillecitoyenne.fr/courses/javascript/lesson6/sample-data.json](http://blank.bellevillecitoyenne.fr/courses/javascript/lesson6/sample-data.json)\n+* Arretez votre serveur avec `CTRL + C`\n+* Relancez votre serveur\n+* Vérifiez que vos données sont accessibles à [http://localhost:8000/data.json](http://localhost:8000/data.json)\n+\n+\n+## Passons à l'exercice\n+\n+* Créez un fichier `script.js` et incluez le dans votre page HTML\n+* Effectuez une requete AJAX sur l'addresse suivante : [http://localhost:8000/data.json](http://localhost:8000/data.json)\n+* Récupérez la réponse de votre requete avec `this.responseText`. Pour le \"parser\" et le transformer en objet JavaScript vous pouvez utiliser la méthode `parse` de l'objet `JSON` : `JSON.parse(this.responseText)`. Voir la doc ici : [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse)\n+* Interprétez les données en javascript pour générer un HTML cohérant (sous forme de carte ?) */\n+\n+var request = new XMLHttpRequest();\n+var p = document.createElement(\"p\");\n+document.body.appendChild(p);\n+request.open(\"GET\", \"http://localhost:8000/data.json\", true);\n+\n+request.onreadystatechange = function() {\n+    if (this.readyState == 4 && this.status == 200) {\n+        var toto = this.responseText;\n+        var objectAPI = JSON.parse(toto);;\n+    for (i = 0; i < objectAPI.records.length; i++) {\n+        var div = document.createElement(\"div\");\n+        document.body.appendChild(div);\n+        var a = objectAPI.records[i].fields.ap_cp;\n+        var b = objectAPI.records[i].fields.ap_num; \n+        var c = objectAPI.records[i].fields.ap_voie;\n+        var d = objectAPI.records[i].fields.designation_longue;\n+        div.innerHTML = a + \" \" + b + \" \" + \" \"+ c +\" \" + d;","path":"javascript/lesson6/exercise2/main.js","position":46,"original_position":46,"commit_id":"a506053481df5dab665dac0f781f706f5139ca69","original_commit_id":"a506053481df5dab665dac0f781f706f5139ca69","user":{"login":"Neilsafraoui","id":18012806,"node_id":"MDQ6VXNlcjE4MDEyODA2","avatar_url":"https://avatars3.githubusercontent.com/u/18012806?v=4","gravatar_id":"","url":"https://api.github.com/users/Neilsafraoui","html_url":"https://github.com/Neilsafraoui","followers_url":"https://api.github.com/users/Neilsafraoui/followers","following_url":"https://api.github.com/users/Neilsafraoui/following{/other_user}","gists_url":"https://api.github.com/users/Neilsafraoui/gists{/gist_id}","starred_url":"https://api.github.com/users/Neilsafraoui/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Neilsafraoui/subscriptions","organizations_url":"https://api.github.com/users/Neilsafraoui/orgs","repos_url":"https://api.github.com/users/Neilsafraoui/repos","events_url":"https://api.github.com/users/Neilsafraoui/events{/privacy}","received_events_url":"https://api.github.com/users/Neilsafraoui/received_events","type":"User","site_admin":false},"body":"séparer le contenu dans divers balises HTML (au choix)","created_at":"2018-12-10T14:40:04Z","updated_at":"2018-12-10T14:40:16Z","html_url":"https://github.com/blank-4/exercises-yassinezb/pull/16#discussion_r240234692","pull_request_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/pulls/16","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/blank-4/exercises-yassinezb/pulls/comments/240234692"},"html":{"href":"https://github.com/blank-4/exercises-yassinezb/pull/16#discussion_r240234692"},"pull_request":{"href":"https://api.github.com/repos/blank-4/exercises-yassinezb/pulls/16"}}},"pull_request":{"url":"https://api.github.com/repos/blank-4/exercises-yassinezb/pulls/16","id":237281118,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM3MjgxMTE4","html_url":"https://github.com/blank-4/exercises-yassinezb/pull/16","diff_url":"https://github.com/blank-4/exercises-yassinezb/pull/16.diff","patch_url":"https://github.com/blank-4/exercises-yassinezb/pull/16.patch","issue_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/issues/16","number":16,"state":"open","locked":false,"title":"exo1lesson6js","user":{"login":"yassinezb","id":44778602,"node_id":"MDQ6VXNlcjQ0Nzc4NjAy","avatar_url":"https://avatars2.githubusercontent.com/u/44778602?v=4","gravatar_id":"","url":"https://api.github.com/users/yassinezb","html_url":"https://github.com/yassinezb","followers_url":"https://api.github.com/users/yassinezb/followers","following_url":"https://api.github.com/users/yassinezb/following{/other_user}","gists_url":"https://api.github.com/users/yassinezb/gists{/gist_id}","starred_url":"https://api.github.com/users/yassinezb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yassinezb/subscriptions","organizations_url":"https://api.github.com/users/yassinezb/orgs","repos_url":"https://api.github.com/users/yassinezb/repos","events_url":"https://api.github.com/users/yassinezb/events{/privacy}","received_events_url":"https://api.github.com/users/yassinezb/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-12-10T11:10:07Z","updated_at":"2018-12-10T14:40:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cb9d8ec11eaf4b922c48f814f7ad16bd53b55531","assignee":null,"assignees":[],"requested_reviewers":[{"login":"FaXaq","id":5200291,"node_id":"MDQ6VXNlcjUyMDAyOTE=","avatar_url":"https://avatars1.githubusercontent.com/u/5200291?v=4","gravatar_id":"","url":"https://api.github.com/users/FaXaq","html_url":"https://github.com/FaXaq","followers_url":"https://api.github.com/users/FaXaq/followers","following_url":"https://api.github.com/users/FaXaq/following{/other_user}","gists_url":"https://api.github.com/users/FaXaq/gists{/gist_id}","starred_url":"https://api.github.com/users/FaXaq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FaXaq/subscriptions","organizations_url":"https://api.github.com/users/FaXaq/orgs","repos_url":"https://api.github.com/users/FaXaq/repos","events_url":"https://api.github.com/users/FaXaq/events{/privacy}","received_events_url":"https://api.github.com/users/FaXaq/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/pulls/16/commits","review_comments_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/pulls/16/comments","review_comment_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/issues/16/comments","statuses_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/statuses/a506053481df5dab665dac0f781f706f5139ca69","head":{"label":"blank-4:lesson6js","ref":"lesson6js","sha":"a506053481df5dab665dac0f781f706f5139ca69","user":{"login":"blank-4","id":44091235,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ0MDkxMjM1","avatar_url":"https://avatars3.githubusercontent.com/u/44091235?v=4","gravatar_id":"","url":"https://api.github.com/users/blank-4","html_url":"https://github.com/blank-4","followers_url":"https://api.github.com/users/blank-4/followers","following_url":"https://api.github.com/users/blank-4/following{/other_user}","gists_url":"https://api.github.com/users/blank-4/gists{/gist_id}","starred_url":"https://api.github.com/users/blank-4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blank-4/subscriptions","organizations_url":"https://api.github.com/users/blank-4/orgs","repos_url":"https://api.github.com/users/blank-4/repos","events_url":"https://api.github.com/users/blank-4/events{/privacy}","received_events_url":"https://api.github.com/users/blank-4/received_events","type":"Organization","site_admin":false},"repo":{"id":156365544,"node_id":"MDEwOlJlcG9zaXRvcnkxNTYzNjU1NDQ=","name":"exercises-yassinezb","full_name":"blank-4/exercises-yassinezb","private":false,"owner":{"login":"blank-4","id":44091235,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ0MDkxMjM1","avatar_url":"https://avatars3.githubusercontent.com/u/44091235?v=4","gravatar_id":"","url":"https://api.github.com/users/blank-4","html_url":"https://github.com/blank-4","followers_url":"https://api.github.com/users/blank-4/followers","following_url":"https://api.github.com/users/blank-4/following{/other_user}","gists_url":"https://api.github.com/users/blank-4/gists{/gist_id}","starred_url":"https://api.github.com/users/blank-4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blank-4/subscriptions","organizations_url":"https://api.github.com/users/blank-4/orgs","repos_url":"https://api.github.com/users/blank-4/repos","events_url":"https://api.github.com/users/blank-4/events{/privacy}","received_events_url":"https://api.github.com/users/blank-4/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/blank-4/exercises-yassinezb","description":"exercises-yassinezb created by GitHub Classroom","fork":false,"url":"https://api.github.com/repos/blank-4/exercises-yassinezb","forks_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/forks","keys_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/teams","hooks_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/hooks","issue_events_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/issues/events{/number}","events_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/events","assignees_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/assignees{/user}","branches_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/branches{/branch}","tags_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/tags","blobs_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/git/refs{/sha}","trees_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/statuses/{sha}","languages_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/languages","stargazers_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/stargazers","contributors_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/contributors","subscribers_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/subscribers","subscription_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/subscription","commits_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/commits{/sha}","git_commits_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/git/commits{/sha}","comments_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/comments{/number}","issue_comment_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/issues/comments{/number}","contents_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/contents/{+path}","compare_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/merges","archive_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/downloads","issues_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/issues{/number}","pulls_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/pulls{/number}","milestones_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/milestones{/number}","notifications_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/labels{/name}","releases_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/releases{/id}","deployments_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/deployments","created_at":"2018-11-06T10:20:56Z","updated_at":"2018-12-10T09:50:50Z","pushed_at":"2018-12-10T14:30:22Z","git_url":"git://github.com/blank-4/exercises-yassinezb.git","ssh_url":"git@github.com:blank-4/exercises-yassinezb.git","clone_url":"https://github.com/blank-4/exercises-yassinezb.git","svn_url":"https://github.com/blank-4/exercises-yassinezb","homepage":null,"size":15383,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":false,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"blank-4:master","ref":"master","sha":"314b8e7574be524ddd9c22b658a8a5a0cc522b45","user":{"login":"blank-4","id":44091235,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ0MDkxMjM1","avatar_url":"https://avatars3.githubusercontent.com/u/44091235?v=4","gravatar_id":"","url":"https://api.github.com/users/blank-4","html_url":"https://github.com/blank-4","followers_url":"https://api.github.com/users/blank-4/followers","following_url":"https://api.github.com/users/blank-4/following{/other_user}","gists_url":"https://api.github.com/users/blank-4/gists{/gist_id}","starred_url":"https://api.github.com/users/blank-4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blank-4/subscriptions","organizations_url":"https://api.github.com/users/blank-4/orgs","repos_url":"https://api.github.com/users/blank-4/repos","events_url":"https://api.github.com/users/blank-4/events{/privacy}","received_events_url":"https://api.github.com/users/blank-4/received_events","type":"Organization","site_admin":false},"repo":{"id":156365544,"node_id":"MDEwOlJlcG9zaXRvcnkxNTYzNjU1NDQ=","name":"exercises-yassinezb","full_name":"blank-4/exercises-yassinezb","private":false,"owner":{"login":"blank-4","id":44091235,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ0MDkxMjM1","avatar_url":"https://avatars3.githubusercontent.com/u/44091235?v=4","gravatar_id":"","url":"https://api.github.com/users/blank-4","html_url":"https://github.com/blank-4","followers_url":"https://api.github.com/users/blank-4/followers","following_url":"https://api.github.com/users/blank-4/following{/other_user}","gists_url":"https://api.github.com/users/blank-4/gists{/gist_id}","starred_url":"https://api.github.com/users/blank-4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blank-4/subscriptions","organizations_url":"https://api.github.com/users/blank-4/orgs","repos_url":"https://api.github.com/users/blank-4/repos","events_url":"https://api.github.com/users/blank-4/events{/privacy}","received_events_url":"https://api.github.com/users/blank-4/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/blank-4/exercises-yassinezb","description":"exercises-yassinezb created by GitHub Classroom","fork":false,"url":"https://api.github.com/repos/blank-4/exercises-yassinezb","forks_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/forks","keys_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/teams","hooks_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/hooks","issue_events_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/issues/events{/number}","events_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/events","assignees_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/assignees{/user}","branches_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/branches{/branch}","tags_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/tags","blobs_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/git/refs{/sha}","trees_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/statuses/{sha}","languages_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/languages","stargazers_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/stargazers","contributors_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/contributors","subscribers_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/subscribers","subscription_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/subscription","commits_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/commits{/sha}","git_commits_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/git/commits{/sha}","comments_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/comments{/number}","issue_comment_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/issues/comments{/number}","contents_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/contents/{+path}","compare_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/merges","archive_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/downloads","issues_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/issues{/number}","pulls_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/pulls{/number}","milestones_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/milestones{/number}","notifications_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/labels{/name}","releases_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/releases{/id}","deployments_url":"https://api.github.com/repos/blank-4/exercises-yassinezb/deployments","created_at":"2018-11-06T10:20:56Z","updated_at":"2018-12-10T09:50:50Z","pushed_at":"2018-12-10T14:30:22Z","git_url":"git://github.com/blank-4/exercises-yassinezb.git","ssh_url":"git@github.com:blank-4/exercises-yassinezb.git","clone_url":"https://github.com/blank-4/exercises-yassinezb.git","svn_url":"https://github.com/blank-4/exercises-yassinezb","homepage":null,"size":15383,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":false,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/blank-4/exercises-yassinezb/pulls/16"},"html":{"href":"https://github.com/blank-4/exercises-yassinezb/pull/16"},"issue":{"href":"https://api.github.com/repos/blank-4/exercises-yassinezb/issues/16"},"comments":{"href":"https://api.github.com/repos/blank-4/exercises-yassinezb/issues/16/comments"},"review_comments":{"href":"https://api.github.com/repos/blank-4/exercises-yassinezb/pulls/16/comments"},"review_comment":{"href":"https://api.github.com/repos/blank-4/exercises-yassinezb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/blank-4/exercises-yassinezb/pulls/16/commits"},"statuses":{"href":"https://api.github.com/repos/blank-4/exercises-yassinezb/statuses/a506053481df5dab665dac0f781f706f5139ca69"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"Neilsafraoui"}}