i have to create ajax call when user clicks on checkboxes to fetch the specific jobs according to each checkbox category. When in controller i return return \Response::json($jobs)
The request works fine. But when im trying to return return View::make('jobs.alljobs')->with('jobs', $jobs);
i got Error 500
JobController.php
$cat = Input::get('categories');
$jobs = Job::whereIn('category_id',$cat)->get();
return View::make('jobs.alljobs')->with('jobs', $jobs);
AJAX Call function
function filterCategories(){
//Mark : Categories filters jquery
var categories = [];
// Listen for 'change' event
$('input[name="cat[]"]').on('change', function (e) {
e.preventDefault();
categories = []; // reset
$('input[name="cat[]"]:checked').each(function()
{
categories.push($(this).val());
});
console.log(categories);
//Send request
$.ajax({
url: '/jobs/searchcat',
type: 'POST',
data: {categories:categories},
beforeSend: function (request) {
return request.setRequestHeader('X-CSRF-Token', $("meta[name='csrf-token']").attr('content'));
},
success: function(response){
console.log(response);
}
})});}
Probably means that your script is throwing an uncaught error or exception when you return the view. Enable error logging and check your logs. Either of these pages might help with that.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.