Passing variables with POST to another page with Jquery

后端 未结 4 1689
[愿得一人]
[愿得一人] 2021-01-11 21:24

I am relatively new to Jquery and I was wondering how would one post variables to another page and then redirect? I used ajax function, the redirect works fine, but no varia

4条回答
  •  旧巷少年郎
    2021-01-11 21:54

    If you like to code less do this:

    1. include jquery.redirect.min.js in your javascript (js) folder.
    2. Load file AFTER JQUERY loading script:

      
      
      
      
    3. Simply replace desired parameters on the next line (copy/paste) in your javascript code:

      $().redirect('targeturl.html', {'post_var_1': 'value1', 'post_var_2': 'value2'});
      

    This is the simplest and the fastest method I have found for posting variables to another page without using the form tag. Good luck!

提交回复
热议问题