0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Laravelの失敗談をまとめてみる

Posted at

Laravelでひっかかったことまとめ

目次

  1. Ajaxを利用してPUTを送信しようとしてRequestが空

1.Ajaxを利用してPUTを送信しようとしてRequestが空

概要

	$.ajax({
		url: url,
		type: 'PUT',
		data: data,
		cache: false,
		contentType: false,
		processData: false,
		dataType: "json"
	}).done(function (data, textStatus, jqXHR) {

こういうプログラムを準備してデータを送信。
F12のdeveloper toolsではformのデータをきちんと飛ばしているのに受け取り側のlaravelで

dd($request->all());

とやっても空

原因

type: 'PUT' じゃなくて、_methodを利用して送信する。すっかり忘れていたよ。(;´д`)トホホ

	data.append('_method', 'PUT');
	$.ajax({
		url: url,
		type: 'POST',
		data: data,
		cache: false,
		contentType: false,
		processData: false,
		dataType: "json"
	}).done(function (data, textStatus, jqXHR) {

これで送信。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?