아약스 요청을 통해 데이터를 게시하려고합니다.Laravel 5.5 MethodNotAllowedHttpException ajax
이 http://mysite/element/edit/을 말한다 내 view.blade.php 내부의 자바 스크립트 코드 {ID}
<script>
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$(function() {
$("#append-content").sortable({ handle: '.composer-row-header-handle' }).bind('sortupdate', function(e, ui) {
var rowID = $('.composer-row').map(function(){
return $(this).attr("id");
}).get();
$.ajax({
type: "POST",
url: "sort/store",
dataType: "json",
data: {
rowID: rowID
},
success: function(order){
console.log(rowID)
},
error: function(){
console.log(rowID)
}
});
});
});
</script>
와 같은 파일 안에 내가 그런 다음 상대 _token 메타
<meta name="csrf-token" content="{{ csrf_token() }}">
를 삽입 한
내 경로 파일
Route::post('element/edit/sort/store', '[email protected]');
을 그리고 내 ElementsCon 내부 POST 경로를 설정 troller 정렬 기능은
public function sort(Request $request)
{
$rowID = $request->input('rowID');
$i = 1;
foreach($rowID as $val) {
$val = str_replace("row-", "", $val);
DB::table('element')
->where('refID', 1)
->where('rowID', $val)
->update(
[
'rowORDER' => $i,
]
);
$i++;
}
}
그러나이다 나는 응답이
jquery-1.12.0.min.js:4 POST http://mysite/element/edit/sort/store 500 (Internal Server Error)
내가 새 페이지의 링크를 열려고하면이 결과
입니다 로그 순서를 변경하려고 할 때 모든 대답
시도'POST ', 그래서 당신은'MethodNotAllowedHttpException'을 얻었습니다. 아약스 호출에 관해서는 laravel 로그 파일을 확인하십시오. – aleksejjj
하지만 아약스에서'POST '유형을 사용하도록 지정했습니다. –
ajex가 어떤 경로를 타는지 확인 했습니까? 댓글에서 언급 한 경로를 누르거나 다른 것을 치는 것입니까? – Imran