8000 Ajax Api · Himanxusharma/JavaScript@625f299 · GitHub
[go: up one dir, main page]

Skip to content

Commit 625f299

Browse files
committed
Ajax Api
1 parent 97417d7 commit 625f299

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

Ajax.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,18 @@
445445
// // async await
446446

447447
// // fetch api
448+
document.getElementById('button1').addEventListener('click',getText)
449+
450+
function getText() {
451+
452+
console.log('getText called');
453+
fetch('data.txt').then(function (res) {
454+
console.log(res.text())
455+
})
456+
457+
}
458+
459+
448460

449461
// // arrow function
450462

index.html

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<!-- Compiled and minified CSS -->
1212
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
13-
13+
<script src="Ajax.js"></script>
1414
<!-- Compiled and minified JavaScript -->
1515
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
1616

@@ -126,9 +126,19 @@ <h2>TOdos </h2>
126126
</div>
127127
</div>
128128

129+
130+
<div class="container">
131+
<div class="readFile">
132+
<button type="button" id="button1" class="btn btn-outline-success">Get Text Data</button>
133+
<button type="button" id="button2" class="btn btn-outline-success">Get JSON</button>
134+
<button type="button" id="button4" class="btn btn-outline-success">Get API Data</button>
135+
<div id="output"></div>
136+
</div>
137+
</div>
138+
129139
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
130140
<script src="myHttp.js"></script>
131-
<script src="Ajax.js"></script>
141+
132142

133143
</body>
134144

0 commit comments

Comments
 (0)
0