search

Home  >  Q&A  >  body text

javascript - post method parameters are converted into parameters spliced ​​on the url by the get method

var param = {
        "regionCodes": "110000,120000,13000",
        "purchaseGroups": "A01,A02",
        "feedBackType": "0",
        "isReplied": "0",
        "bTime": "20170301",
        "eTime": "20170431",
        "page": 0,
        "size": 20
    }

It turns out that the post method can pass parameters directly. Now we use the get method first, so we need to splice the parameters after the url.
Similar form:

/ask?regionCodes=110000,120000,13000&purchaseGroups=A01,A02&feedBackType='0'
...

Write a function but it cannot meet the requirements (cannot handle commas)

function changeParam(param){
        return JSON.stringify(param).replace(/:/g,'=').replace(/,/g,'&').replace(/{/g,'?').replace(/}/g,'').replace(/"/g,'');
    }
求一个函数完美转换的函数
黄舟黄舟2778 days ago888

reply all(1)I'll reply

  • 巴扎黑

    巴扎黑2017-05-19 10:49:42

    http://stackoverflow.com/ques...

    reply
    0
  • Cancelreply