LoginSignup
0
0

More than 1 year has passed since last update.

formタグだけじゃない$_POST

Posted at

formタグにおいてpostメソッドを指定するとフォームに入力された値が連想配列としてPHP $_POSTで使用出来るというのがこれまでの理解でした。

今回jQueryのAjaxでもPOST送信が出来て、PHP $_POSTで使用可能と学んだので備忘録とします。

$.ajax({
        url: 'xxxxxx',
        type: 'post'
        data: {'fruits': apples},
       })

上記の場合宛先となるurl('xxxxxx')にdata('fruits': apple)をPOST送信することができ、
PHPでecho $_POST['fruits']する事でapplesが出力されます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0