我找到了針對(duì)此解決方案的幾種解決方案,并全部嘗試了這些解決方案(csrf令牌,url ..),但似乎都無(wú)法解決。這是我的設(shè)置:html文件: <meta name="csrf-token" content="{{ csrf_token() }}">... <button id="button" class="btn btn-success">Assign Selected</button>...我的js文件:$(document).ready(function () { $('#button').click(function (e) { $.ajaxSetup({ headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') } }); $.ajax({ type: "POST", dataType: 'json', url: '/wptest', data: { data: 'ahoj' } }).done(function (data) { console.log('Ajax was Successful!') console.log(data) }).fail(function () { console.log('Ajax Failed') }); });}和我的web.php文件:Route::post('/wptest','UserController@assignToWP');在我的控制器中,只有一個(gè)簡(jiǎn)單的dd($ request);編輯:網(wǎng)絡(luò)選項(xiàng)卡顯示:200 OK問(wèn)題:?jiǎn)螕舭粹o后,我總是收到Ajax失敗的消息。我想念什么?
- 1 回答
- 0 關(guān)注
- 141 瀏覽
添加回答
舉報(bào)
0/150
提交
取消