古詩詞大全網 - 個性簽名 - html中的js如何獲得通過POST方法傳遞的參數

html中的js如何獲得通過POST方法傳遞的參數

您可以通過解析url路徑來獲取參數:

\ tfunctiongetURLParameter(name){

returndecodeURIComponent((new regexp([?| & amp]'+name+'='+'([^&;;]+?)(& amp|#|;|$)').exec(location.search)||[," "])[1]。replace(/\+/g,' % 20 ')| | null;

\t}

\ tvar orgid = getURLParameter(' orgid ');

\ tvarorglevel = getURLParameter(' org level ');

\ t console . log(' orgid = '+orgid);

\ t console . log(' org level = '+org level);

擴展數據

通過html中的url地址傳遞參數和獲取參數:

varurl = document . location . tostring();//獲取url地址

varurlParmStr = URL . slice(URL . index of('?'))+1);//獲取問號後的所有字符串

vararr = urlparmstr . split(' & amp;'));//Pass &;符號將壹個字符串拆分成壹個數組。

varcourseId=arr[0]。split(" = "[1];//獲取數組中的第壹個參數

varunit_title=arr[1]。split(" = "[1];//第二個參數

unit _ title = decode uri(unit _ title);//轉碼將解碼模式unscape改為decodeURI,獲取中文參數。

console . log(unit _ title);