File tree Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html lang ="en ">
3
+ < head >
4
+ < meta charset ="UTF-8 ">
5
+ < meta name ="viewport " content ="width=device-width, initial-scale=1 ">
6
+ < title > Web Fetch API for a GET request</ title >
7
+ </ head >
8
+ < body >
9
+ < div id ="books "> </ div >
10
+ < script >
11
+ // https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
12
+
13
+ fetch ( 'http://localhost/PHP-Dump/src/ajaxcalldump.php?key1=value1&key2=value2' , {
14
+ method : 'GET'
15
+ } ) . then ( ( reponse ) => {
16
+ // console.log(reponse);
17
+ if ( reponse . ok ) {
18
+ reponse . json ( ) . then ( ( json ) => {
19
+ console . log ( json ) ;
20
+ } )
21
+ }
22
+ } ) ;
23
+ </ script >
24
+ </ body >
25
+ </ html >
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html lang ="en ">
3
+ < head >
4
+ < meta charset ="UTF-8 ">
5
+ < meta name ="viewport " content ="width=device-width, initial-scale=1 ">
6
+ < title > Web Fetch API for a POST request</ title >
7
+ </ head >
8
+ < body >
9
+ < div id ="books "> </ div >
10
+ < script >
11
+ // https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
12
+
13
+ fetch ( 'http://localhost/PHP-Dump/src/ajaxcalldump.php' , {
14
+ method : 'POST' ,
15
+ headers : { 'Content-Type' : 'application/x-www-form-urlencoded' } ,
16
+ body : 'key1=value1&key2=value2'
17
+ } ) . then ( ( reponse ) => {
18
+ // console.log(reponse);
19
+ if ( reponse . ok ) {
20
+ reponse . json ( ) . then ( ( json ) => {
21
+ console . log ( json ) ;
22
+ } )
23
+ }
24
+ } ) ;
25
+ </ script >
26
+ </ body >
27
+ </ html >
You can’t perform that action at this time.
0 commit comments