I'm trying to receive an id by first sending it through ajax and then return it in json format in laravel. For some reason, it's not working, also console shows I'm getting a "Internal server error" for this url: http://localhost/public/admin/questions/sort
What could be wrong here?
jquery code:
<script>
$(document).ready(function () {
//alert(url);
$('select[name=selector]').change(function() {
var quiz_id=$(this).val();
$.ajax({
method: "POST",
url: '',
data:{id:quiz_id}
}).done(function (msg) {
console.log(msg['id']);
})
});
});
</script>
routes file
Route::post('questions/sort',['uses'=>'QuestionController@sort','as'=>'admin.questions.sort']);
Route::resource('questions', 'QuestionController');
controller file
public function sort(Request $request) {
$id=$request['id'];
return response()->json(['id'=>$id ],200);
}
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2jMMAWI
via IFTTT
Aucun commentaire:
Enregistrer un commentaire