How to read the post request parameters using JavaScript

后端 未结 18 1329
自闭症患者
自闭症患者 2020-11-22 16:41

I am trying to read the post request parameters from my HTML. I can read the get request parameters using the following code in JavaScript.

$wnd.location.sea         


        
18条回答
  •  轮回少年
    2020-11-22 17:08

    One option is to set a cookie in PHP.

    For example: a cookie named invalid with the value of $invalid expiring in 1 day:

    setcookie('invalid', $invalid, time() + 60 * 60 * 24);
    

    Then read it back out in JS (using the JS Cookie plugin):

    var invalid = Cookies.get('invalid');
    
    if(invalid !== undefined) {
        Cookies.remove('invalid');
    }
    

    You can now access the value from the invalid variable in JavaScript.

提交回复
热议问题