Send a GET request using the tool AJAX method in jQuery

 1     $(".get").click(function () {
 2         //  Use the AJAX request in jQuery
 3         $.ajax({
 4             //  Set request method
 5             method: "GET",
 6             //  Request address
 7             url: "/xhr",
 8 
 9             //  Configure the send request data format, the default urlencoded value If the FORMDATA data is sent, the property is changed to false.
10             contentType: "application/x-www-form-urlencoded",
11 
12             //  Request data
13         data: {
14                                  Username: "Zhang San",
15                 age: "20",
16                                  Hobby: ["Singing", "Will jump "],
17          },
18             //  Configuring data format default JSON
19             dataType: "json",
20 
21             //  Request success
22             success: function (res) {
23                 console.log(res);
24             }
25         })
26    })
1 app.get("/xhr", function (req, res) {
2     res.json({
3         msg: "success"
4     })
5 })

Read more here: Source link