LoginSignup
1
0

More than 5 years have passed since last update.

jQueryでpostする時のHeaderをいじる(csrftokenの設定とか)

Posted at

https://readouble.com/laravel/5.5/ja/csrf.html
https://stackoverflow.com/questions/7100294/json-post-with-customized-httpheader-fiel

LaravelでPostする時、デフォルト設定だとcsrf tokenをヘッダーに埋め込む。

基本マニュアル通りやればいいんだけど、何も考えずに設定するとjQuery全体に設定が効いてしまうので、外部APIとか叩く際にNGな事がある。

じゃあpostする時に設定すればいいや、となるんだが、jQuery.postだとヘッダーはいじれないので、jQuery.ajax でやるとOK。

1
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
1
0