Laravel yajra datatable: cannot retrieve the search parameter from ajax call in controller











up vote
0
down vote

favorite












I am trying to build a dataTable with custom filtering with the help of yajra datatable from here :



HTML table in view :



  <form id="search-form" class="form-inline" method="POST" role="form" action="#">


<select id="batch" name="batch">
<option value="">Select</option>
<option value="22">Skill Level CBE Dec 2018</option>
<option value="2">Batch 2</option>

</select>

<button class="btn btn-primary" type="submit">Search</button>

</form>

<table class="table table-striped table-bordered datatable" cellspacing="0" width="100%">

<thead>

<tr>



<th>{{ getPhrase('S/N')}}</th>

<th>{{ getPhrase('Batch')}}</th>
<th>{{ getPhrase('Course')}}</th>
<th>{{ getPhrase('Subject')}}</th>

<th>{{ getPhrase('title')}}</th>

<th>{{ getPhrase('otq_marks')}}</th>
<th>{{ getPhrase('cr_marks')}}</th>

<th>{{ getPhrase('total')}}</th>
<th>{{ getPhrase('average')}}</th>




</tr>

</thead>



</table>


@section('footer_scripts')



@include('common.datatables', array('route'=>URL_STUDENT_EXAM_GETATTEMPTS.$user->slug, 'route_as_url' => 'TRUE'))


@stop


As to common.datatables, datatables.blade.php has :



$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});

tableObj = $('.datatable').DataTable({
processing: true,
serverSide: true,
retrieve :true,
// cache: true,
type: 'GET',

ajax: {
url: '{{ $routeValue }}',
data: function (d) {
d.batch = $('#batch').val();

}
}



});


$('#search-form').on('submit', function(e) {
tableObj.draw();
e.preventDefault();
});


ajax url value $routeValue refers to URL_STUDENT_EXAM_GETATTEMPTS constant (to be clarified later) used in view in whatever way.



When I select a value from the "batch" drop-down and press the submit button, an ajax call is made to the route. In browser inspection tool, I see that a lot of query parameters are added in the ajax URL and our batch param is also there. Now I need to retrieve that batch parameter inside the controller.



Now about the server side code :



The constant URL_STUDENT_EXAM_GETATTEMPTS used in blade has the value PREFIX.'exams/student/get-exam-attempts/'



And in route.php, the route is defined as :



Route::get('exams/student/get-exam-attempts/{user_slug}/{exam_slug?}', 'StudentQuizController@getExamAttemptsData');


In controller I have :



public function getExamAttemptsData(Request $request,$slug, $exam_slug = '')
{

//body goes here

}


I have used all the following methods to get the batch parameter in the controller but in vain :



$request->get('batch')
$request->query('batch')
Input::get('batch')


How can I retrieve the value of batch inside the controller ?



EDIT: BTW I am using use IlluminateHttpRequest; for the Request $request variable in controller function parameter



EDIT2: The browser inspection tool shows the ajax request url as :



http:// localhost/lcbs/exams/student/get-exam-attempts/myuser123 ?draw=2&columns%5B0%5D%5Bdata%5D=0......search%5Bregex%5D=false&batch=22&_=1541684388689.



So you see that batch is there in the query parameters.
But inside the controller, the code $request->getQueryString() only shows
%2Fexams%2Fstudent%2Fget-exam-attempts%2Fmyuser123



And URL::current() shows http:// localhost/lcbs/exams/student/get-exam-attempts/myuser123



That means, the $request misses the complete query string.










share|improve this question
























  • What happens, when you check the $_GET['batch'] superglobal in your controller? I know, that this is not the best solution, but you should check this just for debugging.
    – ISTI
    Nov 8 at 21:36












  • @ISTI, empty output
    – Istiaque Ahmed
    Nov 9 at 15:35















up vote
0
down vote

favorite












I am trying to build a dataTable with custom filtering with the help of yajra datatable from here :



HTML table in view :



  <form id="search-form" class="form-inline" method="POST" role="form" action="#">


<select id="batch" name="batch">
<option value="">Select</option>
<option value="22">Skill Level CBE Dec 2018</option>
<option value="2">Batch 2</option>

</select>

<button class="btn btn-primary" type="submit">Search</button>

</form>

<table class="table table-striped table-bordered datatable" cellspacing="0" width="100%">

<thead>

<tr>



<th>{{ getPhrase('S/N')}}</th>

<th>{{ getPhrase('Batch')}}</th>
<th>{{ getPhrase('Course')}}</th>
<th>{{ getPhrase('Subject')}}</th>

<th>{{ getPhrase('title')}}</th>

<th>{{ getPhrase('otq_marks')}}</th>
<th>{{ getPhrase('cr_marks')}}</th>

<th>{{ getPhrase('total')}}</th>
<th>{{ getPhrase('average')}}</th>




</tr>

</thead>



</table>


@section('footer_scripts')



@include('common.datatables', array('route'=>URL_STUDENT_EXAM_GETATTEMPTS.$user->slug, 'route_as_url' => 'TRUE'))


@stop


As to common.datatables, datatables.blade.php has :



$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});

tableObj = $('.datatable').DataTable({
processing: true,
serverSide: true,
retrieve :true,
// cache: true,
type: 'GET',

ajax: {
url: '{{ $routeValue }}',
data: function (d) {
d.batch = $('#batch').val();

}
}



});


$('#search-form').on('submit', function(e) {
tableObj.draw();
e.preventDefault();
});


ajax url value $routeValue refers to URL_STUDENT_EXAM_GETATTEMPTS constant (to be clarified later) used in view in whatever way.



When I select a value from the "batch" drop-down and press the submit button, an ajax call is made to the route. In browser inspection tool, I see that a lot of query parameters are added in the ajax URL and our batch param is also there. Now I need to retrieve that batch parameter inside the controller.



Now about the server side code :



The constant URL_STUDENT_EXAM_GETATTEMPTS used in blade has the value PREFIX.'exams/student/get-exam-attempts/'



And in route.php, the route is defined as :



Route::get('exams/student/get-exam-attempts/{user_slug}/{exam_slug?}', 'StudentQuizController@getExamAttemptsData');


In controller I have :



public function getExamAttemptsData(Request $request,$slug, $exam_slug = '')
{

//body goes here

}


I have used all the following methods to get the batch parameter in the controller but in vain :



$request->get('batch')
$request->query('batch')
Input::get('batch')


How can I retrieve the value of batch inside the controller ?



EDIT: BTW I am using use IlluminateHttpRequest; for the Request $request variable in controller function parameter



EDIT2: The browser inspection tool shows the ajax request url as :



http:// localhost/lcbs/exams/student/get-exam-attempts/myuser123 ?draw=2&columns%5B0%5D%5Bdata%5D=0......search%5Bregex%5D=false&batch=22&_=1541684388689.



So you see that batch is there in the query parameters.
But inside the controller, the code $request->getQueryString() only shows
%2Fexams%2Fstudent%2Fget-exam-attempts%2Fmyuser123



And URL::current() shows http:// localhost/lcbs/exams/student/get-exam-attempts/myuser123



That means, the $request misses the complete query string.










share|improve this question
























  • What happens, when you check the $_GET['batch'] superglobal in your controller? I know, that this is not the best solution, but you should check this just for debugging.
    – ISTI
    Nov 8 at 21:36












  • @ISTI, empty output
    – Istiaque Ahmed
    Nov 9 at 15:35













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I am trying to build a dataTable with custom filtering with the help of yajra datatable from here :



HTML table in view :



  <form id="search-form" class="form-inline" method="POST" role="form" action="#">


<select id="batch" name="batch">
<option value="">Select</option>
<option value="22">Skill Level CBE Dec 2018</option>
<option value="2">Batch 2</option>

</select>

<button class="btn btn-primary" type="submit">Search</button>

</form>

<table class="table table-striped table-bordered datatable" cellspacing="0" width="100%">

<thead>

<tr>



<th>{{ getPhrase('S/N')}}</th>

<th>{{ getPhrase('Batch')}}</th>
<th>{{ getPhrase('Course')}}</th>
<th>{{ getPhrase('Subject')}}</th>

<th>{{ getPhrase('title')}}</th>

<th>{{ getPhrase('otq_marks')}}</th>
<th>{{ getPhrase('cr_marks')}}</th>

<th>{{ getPhrase('total')}}</th>
<th>{{ getPhrase('average')}}</th>




</tr>

</thead>



</table>


@section('footer_scripts')



@include('common.datatables', array('route'=>URL_STUDENT_EXAM_GETATTEMPTS.$user->slug, 'route_as_url' => 'TRUE'))


@stop


As to common.datatables, datatables.blade.php has :



$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});

tableObj = $('.datatable').DataTable({
processing: true,
serverSide: true,
retrieve :true,
// cache: true,
type: 'GET',

ajax: {
url: '{{ $routeValue }}',
data: function (d) {
d.batch = $('#batch').val();

}
}



});


$('#search-form').on('submit', function(e) {
tableObj.draw();
e.preventDefault();
});


ajax url value $routeValue refers to URL_STUDENT_EXAM_GETATTEMPTS constant (to be clarified later) used in view in whatever way.



When I select a value from the "batch" drop-down and press the submit button, an ajax call is made to the route. In browser inspection tool, I see that a lot of query parameters are added in the ajax URL and our batch param is also there. Now I need to retrieve that batch parameter inside the controller.



Now about the server side code :



The constant URL_STUDENT_EXAM_GETATTEMPTS used in blade has the value PREFIX.'exams/student/get-exam-attempts/'



And in route.php, the route is defined as :



Route::get('exams/student/get-exam-attempts/{user_slug}/{exam_slug?}', 'StudentQuizController@getExamAttemptsData');


In controller I have :



public function getExamAttemptsData(Request $request,$slug, $exam_slug = '')
{

//body goes here

}


I have used all the following methods to get the batch parameter in the controller but in vain :



$request->get('batch')
$request->query('batch')
Input::get('batch')


How can I retrieve the value of batch inside the controller ?



EDIT: BTW I am using use IlluminateHttpRequest; for the Request $request variable in controller function parameter



EDIT2: The browser inspection tool shows the ajax request url as :



http:// localhost/lcbs/exams/student/get-exam-attempts/myuser123 ?draw=2&columns%5B0%5D%5Bdata%5D=0......search%5Bregex%5D=false&batch=22&_=1541684388689.



So you see that batch is there in the query parameters.
But inside the controller, the code $request->getQueryString() only shows
%2Fexams%2Fstudent%2Fget-exam-attempts%2Fmyuser123



And URL::current() shows http:// localhost/lcbs/exams/student/get-exam-attempts/myuser123



That means, the $request misses the complete query string.










share|improve this question















I am trying to build a dataTable with custom filtering with the help of yajra datatable from here :



HTML table in view :



  <form id="search-form" class="form-inline" method="POST" role="form" action="#">


<select id="batch" name="batch">
<option value="">Select</option>
<option value="22">Skill Level CBE Dec 2018</option>
<option value="2">Batch 2</option>

</select>

<button class="btn btn-primary" type="submit">Search</button>

</form>

<table class="table table-striped table-bordered datatable" cellspacing="0" width="100%">

<thead>

<tr>



<th>{{ getPhrase('S/N')}}</th>

<th>{{ getPhrase('Batch')}}</th>
<th>{{ getPhrase('Course')}}</th>
<th>{{ getPhrase('Subject')}}</th>

<th>{{ getPhrase('title')}}</th>

<th>{{ getPhrase('otq_marks')}}</th>
<th>{{ getPhrase('cr_marks')}}</th>

<th>{{ getPhrase('total')}}</th>
<th>{{ getPhrase('average')}}</th>




</tr>

</thead>



</table>


@section('footer_scripts')



@include('common.datatables', array('route'=>URL_STUDENT_EXAM_GETATTEMPTS.$user->slug, 'route_as_url' => 'TRUE'))


@stop


As to common.datatables, datatables.blade.php has :



$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});

tableObj = $('.datatable').DataTable({
processing: true,
serverSide: true,
retrieve :true,
// cache: true,
type: 'GET',

ajax: {
url: '{{ $routeValue }}',
data: function (d) {
d.batch = $('#batch').val();

}
}



});


$('#search-form').on('submit', function(e) {
tableObj.draw();
e.preventDefault();
});


ajax url value $routeValue refers to URL_STUDENT_EXAM_GETATTEMPTS constant (to be clarified later) used in view in whatever way.



When I select a value from the "batch" drop-down and press the submit button, an ajax call is made to the route. In browser inspection tool, I see that a lot of query parameters are added in the ajax URL and our batch param is also there. Now I need to retrieve that batch parameter inside the controller.



Now about the server side code :



The constant URL_STUDENT_EXAM_GETATTEMPTS used in blade has the value PREFIX.'exams/student/get-exam-attempts/'



And in route.php, the route is defined as :



Route::get('exams/student/get-exam-attempts/{user_slug}/{exam_slug?}', 'StudentQuizController@getExamAttemptsData');


In controller I have :



public function getExamAttemptsData(Request $request,$slug, $exam_slug = '')
{

//body goes here

}


I have used all the following methods to get the batch parameter in the controller but in vain :



$request->get('batch')
$request->query('batch')
Input::get('batch')


How can I retrieve the value of batch inside the controller ?



EDIT: BTW I am using use IlluminateHttpRequest; for the Request $request variable in controller function parameter



EDIT2: The browser inspection tool shows the ajax request url as :



http:// localhost/lcbs/exams/student/get-exam-attempts/myuser123 ?draw=2&columns%5B0%5D%5Bdata%5D=0......search%5Bregex%5D=false&batch=22&_=1541684388689.



So you see that batch is there in the query parameters.
But inside the controller, the code $request->getQueryString() only shows
%2Fexams%2Fstudent%2Fget-exam-attempts%2Fmyuser123



And URL::current() shows http:// localhost/lcbs/exams/student/get-exam-attempts/myuser123



That means, the $request misses the complete query string.







laravel datatable yajra-datatable






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 8 at 13:59

























asked Nov 8 at 13:18









Istiaque Ahmed

1,793124380




1,793124380












  • What happens, when you check the $_GET['batch'] superglobal in your controller? I know, that this is not the best solution, but you should check this just for debugging.
    – ISTI
    Nov 8 at 21:36












  • @ISTI, empty output
    – Istiaque Ahmed
    Nov 9 at 15:35


















  • What happens, when you check the $_GET['batch'] superglobal in your controller? I know, that this is not the best solution, but you should check this just for debugging.
    – ISTI
    Nov 8 at 21:36












  • @ISTI, empty output
    – Istiaque Ahmed
    Nov 9 at 15:35
















What happens, when you check the $_GET['batch'] superglobal in your controller? I know, that this is not the best solution, but you should check this just for debugging.
– ISTI
Nov 8 at 21:36






What happens, when you check the $_GET['batch'] superglobal in your controller? I know, that this is not the best solution, but you should check this just for debugging.
– ISTI
Nov 8 at 21:36














@ISTI, empty output
– Istiaque Ahmed
Nov 9 at 15:35




@ISTI, empty output
– Istiaque Ahmed
Nov 9 at 15:35












1 Answer
1






active

oldest

votes

















up vote
0
down vote













Looks like the ? in the Route is not used to define an optional parameter but a string instead:



Route::get('exams/student/get-exam-attempts/{user_slug}/{exam_slug?}', 'StudentQuizController@getExamAttemptsData');


Could you please change it and see what you get?



Route::get('exams/student/get-exam-attempts/{user_slug}/{exam_slug}', 'StudentQuizController@getExamAttemptsData');


Also, the query string you posted has a space after myyser123, this could also explain the issue.



http:// localhost/lcbs/exams/student/get-exam-attempts/myuser123 ?draw=2&columns%5B0%5D%5Bdata%5D=0......search%5Bregex%5D=false&batch=22&_=1541684388689.


So I would suggest to check how the value is defined in the javascript code



url: '{{ $routeValue }}',





share|improve this answer





















  • exam_slug is an optional parameter, so no way to make it mandatory. As to the space after myuser123, I added it intentionally while writing in SO so that the link just becomes text without being any actual link because the link points to localhost not any online site.
    – Istiaque Ahmed
    Nov 9 at 15:37












  • Can you check that there is no redirect that may be redirecting? Do the other get parameters, drag, columns,.... appear in the Request object?
    – Adrian Hernandez-Lopez
    Nov 10 at 17:54










  • if redirection would be there, then the yajra table would not display. Other parameters are also unavailable. But I found that with Request::getRequestUri();, I can get the whole url except the 'localhost' part. From then I can explode the url string by using & as the delimiter and get all params in an array and from that array I can look for whether a certain param (i.e. 'batch') is there and can use that.
    – Istiaque Ahmed
    Nov 10 at 18:41












  • Does $request->input('batch') also return empty? And also, what output do you get from $request->all();?
    – Adrian Hernandez-Lopez
    Nov 12 at 15:36












  • $request->input('batch') is empty and var_dump($request->all()); gives array(1) { ["/exams/student/get-exam-attempts/myuser123"]=> string(0) "" }
    – Istiaque Ahmed
    Nov 15 at 6:26











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53208578%2flaravel-yajra-datatable-cannot-retrieve-the-search-parameter-from-ajax-call-in%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













Looks like the ? in the Route is not used to define an optional parameter but a string instead:



Route::get('exams/student/get-exam-attempts/{user_slug}/{exam_slug?}', 'StudentQuizController@getExamAttemptsData');


Could you please change it and see what you get?



Route::get('exams/student/get-exam-attempts/{user_slug}/{exam_slug}', 'StudentQuizController@getExamAttemptsData');


Also, the query string you posted has a space after myyser123, this could also explain the issue.



http:// localhost/lcbs/exams/student/get-exam-attempts/myuser123 ?draw=2&columns%5B0%5D%5Bdata%5D=0......search%5Bregex%5D=false&batch=22&_=1541684388689.


So I would suggest to check how the value is defined in the javascript code



url: '{{ $routeValue }}',





share|improve this answer





















  • exam_slug is an optional parameter, so no way to make it mandatory. As to the space after myuser123, I added it intentionally while writing in SO so that the link just becomes text without being any actual link because the link points to localhost not any online site.
    – Istiaque Ahmed
    Nov 9 at 15:37












  • Can you check that there is no redirect that may be redirecting? Do the other get parameters, drag, columns,.... appear in the Request object?
    – Adrian Hernandez-Lopez
    Nov 10 at 17:54










  • if redirection would be there, then the yajra table would not display. Other parameters are also unavailable. But I found that with Request::getRequestUri();, I can get the whole url except the 'localhost' part. From then I can explode the url string by using & as the delimiter and get all params in an array and from that array I can look for whether a certain param (i.e. 'batch') is there and can use that.
    – Istiaque Ahmed
    Nov 10 at 18:41












  • Does $request->input('batch') also return empty? And also, what output do you get from $request->all();?
    – Adrian Hernandez-Lopez
    Nov 12 at 15:36












  • $request->input('batch') is empty and var_dump($request->all()); gives array(1) { ["/exams/student/get-exam-attempts/myuser123"]=> string(0) "" }
    – Istiaque Ahmed
    Nov 15 at 6:26















up vote
0
down vote













Looks like the ? in the Route is not used to define an optional parameter but a string instead:



Route::get('exams/student/get-exam-attempts/{user_slug}/{exam_slug?}', 'StudentQuizController@getExamAttemptsData');


Could you please change it and see what you get?



Route::get('exams/student/get-exam-attempts/{user_slug}/{exam_slug}', 'StudentQuizController@getExamAttemptsData');


Also, the query string you posted has a space after myyser123, this could also explain the issue.



http:// localhost/lcbs/exams/student/get-exam-attempts/myuser123 ?draw=2&columns%5B0%5D%5Bdata%5D=0......search%5Bregex%5D=false&batch=22&_=1541684388689.


So I would suggest to check how the value is defined in the javascript code



url: '{{ $routeValue }}',





share|improve this answer





















  • exam_slug is an optional parameter, so no way to make it mandatory. As to the space after myuser123, I added it intentionally while writing in SO so that the link just becomes text without being any actual link because the link points to localhost not any online site.
    – Istiaque Ahmed
    Nov 9 at 15:37












  • Can you check that there is no redirect that may be redirecting? Do the other get parameters, drag, columns,.... appear in the Request object?
    – Adrian Hernandez-Lopez
    Nov 10 at 17:54










  • if redirection would be there, then the yajra table would not display. Other parameters are also unavailable. But I found that with Request::getRequestUri();, I can get the whole url except the 'localhost' part. From then I can explode the url string by using & as the delimiter and get all params in an array and from that array I can look for whether a certain param (i.e. 'batch') is there and can use that.
    – Istiaque Ahmed
    Nov 10 at 18:41












  • Does $request->input('batch') also return empty? And also, what output do you get from $request->all();?
    – Adrian Hernandez-Lopez
    Nov 12 at 15:36












  • $request->input('batch') is empty and var_dump($request->all()); gives array(1) { ["/exams/student/get-exam-attempts/myuser123"]=> string(0) "" }
    – Istiaque Ahmed
    Nov 15 at 6:26













up vote
0
down vote










up vote
0
down vote









Looks like the ? in the Route is not used to define an optional parameter but a string instead:



Route::get('exams/student/get-exam-attempts/{user_slug}/{exam_slug?}', 'StudentQuizController@getExamAttemptsData');


Could you please change it and see what you get?



Route::get('exams/student/get-exam-attempts/{user_slug}/{exam_slug}', 'StudentQuizController@getExamAttemptsData');


Also, the query string you posted has a space after myyser123, this could also explain the issue.



http:// localhost/lcbs/exams/student/get-exam-attempts/myuser123 ?draw=2&columns%5B0%5D%5Bdata%5D=0......search%5Bregex%5D=false&batch=22&_=1541684388689.


So I would suggest to check how the value is defined in the javascript code



url: '{{ $routeValue }}',





share|improve this answer












Looks like the ? in the Route is not used to define an optional parameter but a string instead:



Route::get('exams/student/get-exam-attempts/{user_slug}/{exam_slug?}', 'StudentQuizController@getExamAttemptsData');


Could you please change it and see what you get?



Route::get('exams/student/get-exam-attempts/{user_slug}/{exam_slug}', 'StudentQuizController@getExamAttemptsData');


Also, the query string you posted has a space after myyser123, this could also explain the issue.



http:// localhost/lcbs/exams/student/get-exam-attempts/myuser123 ?draw=2&columns%5B0%5D%5Bdata%5D=0......search%5Bregex%5D=false&batch=22&_=1541684388689.


So I would suggest to check how the value is defined in the javascript code



url: '{{ $routeValue }}',






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 9 at 7:15









Adrian Hernandez-Lopez

265112




265112












  • exam_slug is an optional parameter, so no way to make it mandatory. As to the space after myuser123, I added it intentionally while writing in SO so that the link just becomes text without being any actual link because the link points to localhost not any online site.
    – Istiaque Ahmed
    Nov 9 at 15:37












  • Can you check that there is no redirect that may be redirecting? Do the other get parameters, drag, columns,.... appear in the Request object?
    – Adrian Hernandez-Lopez
    Nov 10 at 17:54










  • if redirection would be there, then the yajra table would not display. Other parameters are also unavailable. But I found that with Request::getRequestUri();, I can get the whole url except the 'localhost' part. From then I can explode the url string by using & as the delimiter and get all params in an array and from that array I can look for whether a certain param (i.e. 'batch') is there and can use that.
    – Istiaque Ahmed
    Nov 10 at 18:41












  • Does $request->input('batch') also return empty? And also, what output do you get from $request->all();?
    – Adrian Hernandez-Lopez
    Nov 12 at 15:36












  • $request->input('batch') is empty and var_dump($request->all()); gives array(1) { ["/exams/student/get-exam-attempts/myuser123"]=> string(0) "" }
    – Istiaque Ahmed
    Nov 15 at 6:26


















  • exam_slug is an optional parameter, so no way to make it mandatory. As to the space after myuser123, I added it intentionally while writing in SO so that the link just becomes text without being any actual link because the link points to localhost not any online site.
    – Istiaque Ahmed
    Nov 9 at 15:37












  • Can you check that there is no redirect that may be redirecting? Do the other get parameters, drag, columns,.... appear in the Request object?
    – Adrian Hernandez-Lopez
    Nov 10 at 17:54










  • if redirection would be there, then the yajra table would not display. Other parameters are also unavailable. But I found that with Request::getRequestUri();, I can get the whole url except the 'localhost' part. From then I can explode the url string by using & as the delimiter and get all params in an array and from that array I can look for whether a certain param (i.e. 'batch') is there and can use that.
    – Istiaque Ahmed
    Nov 10 at 18:41












  • Does $request->input('batch') also return empty? And also, what output do you get from $request->all();?
    – Adrian Hernandez-Lopez
    Nov 12 at 15:36












  • $request->input('batch') is empty and var_dump($request->all()); gives array(1) { ["/exams/student/get-exam-attempts/myuser123"]=> string(0) "" }
    – Istiaque Ahmed
    Nov 15 at 6:26
















exam_slug is an optional parameter, so no way to make it mandatory. As to the space after myuser123, I added it intentionally while writing in SO so that the link just becomes text without being any actual link because the link points to localhost not any online site.
– Istiaque Ahmed
Nov 9 at 15:37






exam_slug is an optional parameter, so no way to make it mandatory. As to the space after myuser123, I added it intentionally while writing in SO so that the link just becomes text without being any actual link because the link points to localhost not any online site.
– Istiaque Ahmed
Nov 9 at 15:37














Can you check that there is no redirect that may be redirecting? Do the other get parameters, drag, columns,.... appear in the Request object?
– Adrian Hernandez-Lopez
Nov 10 at 17:54




Can you check that there is no redirect that may be redirecting? Do the other get parameters, drag, columns,.... appear in the Request object?
– Adrian Hernandez-Lopez
Nov 10 at 17:54












if redirection would be there, then the yajra table would not display. Other parameters are also unavailable. But I found that with Request::getRequestUri();, I can get the whole url except the 'localhost' part. From then I can explode the url string by using & as the delimiter and get all params in an array and from that array I can look for whether a certain param (i.e. 'batch') is there and can use that.
– Istiaque Ahmed
Nov 10 at 18:41






if redirection would be there, then the yajra table would not display. Other parameters are also unavailable. But I found that with Request::getRequestUri();, I can get the whole url except the 'localhost' part. From then I can explode the url string by using & as the delimiter and get all params in an array and from that array I can look for whether a certain param (i.e. 'batch') is there and can use that.
– Istiaque Ahmed
Nov 10 at 18:41














Does $request->input('batch') also return empty? And also, what output do you get from $request->all();?
– Adrian Hernandez-Lopez
Nov 12 at 15:36






Does $request->input('batch') also return empty? And also, what output do you get from $request->all();?
– Adrian Hernandez-Lopez
Nov 12 at 15:36














$request->input('batch') is empty and var_dump($request->all()); gives array(1) { ["/exams/student/get-exam-attempts/myuser123"]=> string(0) "" }
– Istiaque Ahmed
Nov 15 at 6:26




$request->input('batch') is empty and var_dump($request->all()); gives array(1) { ["/exams/student/get-exam-attempts/myuser123"]=> string(0) "" }
– Istiaque Ahmed
Nov 15 at 6:26


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53208578%2flaravel-yajra-datatable-cannot-retrieve-the-search-parameter-from-ajax-call-in%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Guess what letter conforming each word

Port of Spain

Run scheduled task as local user group (not BUILTIN)