gogoWebsite

【js】js sends a get request

Updated to 21 days ago

Send network requests using native js

var httpRequest = new XMLHttpRequest();//Step 1: Create the required object
         ('GET', 'url', true);//Step 2: Open the connection Write the request parameter in the url ps:"http://localhost:8080/rest/xxx"
         ();//Step 3: Send a request Write the request parameters in the URL
         /**
          * Processor after obtaining data
          */
          = function () {
             if ( == 4 && == 200) {
                 var json = ;//Get the json string and need to be parsed
                 (json);
             }
         };