我不能將我的數據發佈到我的控制器,我的ajax調用有什麼問題嗎?我的設置爲web.php,或者是控制器沒有設置,我得到的錯誤是。提醒這是局部如何在Laravel 5.4中發佈數據控制器?
運行POST http://127.0.0.1:8000/change-rank 500(內部服務器錯誤)
JS
$('.rank-select').change(function(){
var id = $(this).val();
var memberId = $(this).closest('.irmember').attr('id');
console.log(id);
console.log(memberId);
$.ajax({
type: "POST",
url: 'change-rank',
data: {id: id, memberId, memberId},
success: function(msg) {
console.log(msg);
}
});
})
web.php
Route::post('change-rank', '[email protected]');
RankController.php
namespace App\Http\Controllers;
use App\Rank;
use Illuminate\Http\Request;
class RankController extends Controller
{
public function changeRank()
{
info("hi");
}
}
什麼是info()函數? –
在Laravel中它充當日誌,所以如果是成功的,我會在日誌文件中看到「hi」 – Jeremy
很酷,不知道'Laravel'具有這個功能。提出請求時,您在網絡選項卡中收到的回覆是什麼?如果你沒有在你的'laravel.log'中得到什麼錯誤(我會建議先清除日誌)。 –