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.
laravel datatable yajra-datatable
add a comment |
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.
laravel datatable yajra-datatable
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
add a comment |
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.
laravel datatable yajra-datatable
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
laravel datatable yajra-datatable
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
add a comment |
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
add a comment |
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 }}',
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 withRequest::getRequestUri();
, I can get the whole url except the 'localhost' part. From then I canexplode
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 andvar_dump($request->all());
givesarray(1) { ["/exams/student/get-exam-attempts/myuser123"]=> string(0) "" }
– Istiaque Ahmed
Nov 15 at 6:26
|
show 3 more comments
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 }}',
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 withRequest::getRequestUri();
, I can get the whole url except the 'localhost' part. From then I canexplode
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 andvar_dump($request->all());
givesarray(1) { ["/exams/student/get-exam-attempts/myuser123"]=> string(0) "" }
– Istiaque Ahmed
Nov 15 at 6:26
|
show 3 more comments
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 }}',
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 withRequest::getRequestUri();
, I can get the whole url except the 'localhost' part. From then I canexplode
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 andvar_dump($request->all());
givesarray(1) { ["/exams/student/get-exam-attempts/myuser123"]=> string(0) "" }
– Istiaque Ahmed
Nov 15 at 6:26
|
show 3 more comments
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 }}',
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 }}',
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 withRequest::getRequestUri();
, I can get the whole url except the 'localhost' part. From then I canexplode
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 andvar_dump($request->all());
givesarray(1) { ["/exams/student/get-exam-attempts/myuser123"]=> string(0) "" }
– Istiaque Ahmed
Nov 15 at 6:26
|
show 3 more comments
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 withRequest::getRequestUri();
, I can get the whole url except the 'localhost' part. From then I canexplode
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 andvar_dump($request->all());
givesarray(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
|
show 3 more comments
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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