1fetch('https://api.covid19api.com/summary')
2 .then(response => response.json())
3 .then(data => console.log(data))
4 .catch(err => {
5 console.log(err)
6 });
1var id = empid;
2
3$.ajax({
4 type: "POST",
5 url: "../Webservices/EmployeeService.asmx/GetEmployeeOrders",
6 data: "{empid: " + empid + "}",
7 contentType: "application/json; charset=utf-8",
8 dataType: "json",
9 success: function(result){
10 alert(result.d);
11 console.log(result);
12 }
13});
14
1//Change the text of a <div> element using an AJAX //request:
2//using JQuery
3
4
5$("button").click(function(){
6 $.ajax({url: "demo_test.txt", success: function(result){
7 $("#div1").html(result);
8 }});
9});
10
11
12
13//To send a request to a server, we use the open() //and send() methods of the XMLHttpRequest object:
14// Javascript
15
16
17xhttp.open("GET", "ajax_info.txt", true);
18xhttp.send();
19
20//example below
21<html>
22<body>
23
24<h1>The XMLHttpRequest Object</h1>
25
26<button type="button" onclick="loadDoc()">Request data</button>
27
28<p id="demo"></p>
29
30
31<script>
32function loadDoc() {
33 var xhttp = new XMLHttpRequest();
34 xhttp.onreadystatechange = function() {
35 if (this.readyState == 4 && this.status == 200) {
36 document.getElementById("demo").innerHTML = this.responseText;
37 }
38 };
39 xhttp.open("GET", "demo_get.asp", true);
40 xhttp.send();
41}
42</script>
43
44</body>
45</html>