How do I pass along variables with XMLHTTPRequest

后端 未结 7 795
孤街浪徒
孤街浪徒 2020-11-30 03:47

How do I send variables to the server with XMLHTTPRequest? Would I just add them to the end of the URL of the GET request, like ?variable1=?v

相关标签:
7条回答
  • 2020-11-30 04:23

    How about?

    function callHttpService(url, params){
      // Assume params contains key/value request params
      let queryStrings = '';
    
      for(let key in params){
          queryStrings += `${key}=${params[key]}&`
        } 
     const fullUrl = `${url}?queryStrings`
    
      //make http request with fullUrl
    }
    
    0 讨论(0)
提交回复
热议问题