-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwithjquery.html
More file actions
50 lines (48 loc) · 1.63 KB
/
withjquery.html
File metadata and controls
50 lines (48 loc) · 1.63 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<p id="data"></p>
<button>get data</button>
<button>save</button>
<script
src="https://code.jquery.com/jquery-3.7.1.js"
integrity="sha256-eKhayi8LEQwp4NKxN+CfCh+3qOVUtJn3QNZ0TciWLP4="
crossorigin="anonymous"
></script>
<script>
// jquery with get method is a simplified version you can only get value
// $("button").click(function () {
// $.get(
// "https://api.github.com/users/hadley/orgs",
// function (data, status) {
// $("#data").text(JSON.stringify(data)); // hm direct data get nhi krva sakte hme usko json se string me convert krna padega
// }
// );
// });
// jquery ajax method helps with multiple parameters we can also do get post put update delete
$("button").click(function () {
$.ajax({
url: "https://api.github.com/users/hadley/orgs",
success: function (data, status) {
$("#data").text(JSON.stringify(data)); // hm direct data get nhi krva sakte hme usko json se string me convert krna padega
},
});
});
//post method on this url is not allowed so just to give example
// $("button").click(function () {
// $.post(
// "https://code.jquery.com/jquery-3.7.1.js",
// { name: "prachi" },
// function (data, status) {
// alert(status);
// }
// );
// });
</script>
</body>
</html>