0
0

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 5 years have passed since last update.

FuelPHPでAjax通信する際405エラーが出るときの対処法

Posted at

やらかしていたこと

FuelPHPとjQueryのAjaxで

hoge.js
		$.ajax({
			type: "GET",
			url: location.origin + "/ajax/hoge.json",
			dataType: 'json',
			timeout:10000
		}),

上記のような記述で非同期でGETしたいときに405が返ってきた。
ずっとjs側の処理でミスしていたかと思っていたら、
php側で正しいメソッド名が記述できていなかった。

対処法

huga.php
// ミスってた記述例
public function hoge()
{
	 $this->response("success", 200);
}
// 正しい記述例
public function get_hoge()
{
	 $this->response("success", 200);
}

メソッド名の前にget_やpost_を入れないと正しく通信できないのですね。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?