in Education by
I am using datatable with Laravel to order a response that i receive from an API I connect to the API with this code: $ch = curl_init('https://api.turn14.com/v1/items?page=$page'); How you can see i just need to add the $page and it starts to take me all the products from their page, if i add page=1 it takes all the values of the API from the page 1, etc etc The thing is that I am using datatable server side because i want to use all the functionalities that it offers me BUT I do not know how can i pass the number page with the datatable, I mean if I push the number 2 in the button how can i get that value? I mean in the paginator says 1 .. 2 .. 3 etc, if i push 2 how can i know that i pushed in the button 2? Thanks! JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
It would be good to know more about your code. That said, from what I can understand, when you pass the page number to the url - you receive the next page with data from the endpoint. If you are using the Laravel paginator and not something custom, the usual way it works is that it appends a query parameter to the current url: Imagine you have a controller HomeController with a method index: use Illuminate\Http\Request; public function index(Request $request) { dd($request->get('page')); // this will return your current page // Make sure you check the page query parameter first before using it like this. $ch = curl_init('https://api.turn14.com/v1/items?page='.$request->get('page')); return view('home'); } For more information you can read the Laravel docs: https://laravel.com/docs/5.8/pagination#basic-usage By default, the current page is detected by the value of the page query string argument on the HTTP request. This value is automatically detected by Laravel, and is also automatically inserted into links generated by the paginator.

Related questions

0 votes
    We have a big system with hundreds of models (Users, Employees, Payments, Tasks, Projects, and so on ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 15, 2022 in Education by JackTerrance
0 votes
    We have a big system with hundreds of models (Users, Employees, Payments, Tasks, Projects, and so on ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 13, 2022 in Education by JackTerrance
0 votes
    We have a big system with hundreds of models (Users, Employees, Payments, Tasks, Projects, and so on ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 10, 2022 in Education by JackTerrance
0 votes
    We have a big system with hundreds of models (Users, Employees, Payments, Tasks, Projects, and so on ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I have a blade template that creates a form. The form uses a foreach loop to iterate through a ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 10, 2022 in Education by JackTerrance
0 votes
    I have a blade template that creates a form. The form uses a foreach loop to iterate through a ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 22, 2022 in Education by JackTerrance
0 votes
    How can I display images from the storage folder (outside public)? I stored my image files in storage/ ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
0 votes
    I have an html select on my page $query = mysql_query("select * from results"); echo " "; while ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 11, 2022 in Education by JackTerrance
0 votes
    I have an html select on my page $query = mysql_query("select * from results"); echo " "; while ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 6, 2022 in Education by JackTerrance
0 votes
    I have an html select on my page $query = mysql_query("select * from results"); echo " "; while ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 19, 2022 in Education by JackTerrance
0 votes
    Course Results (${courseResponseList.getCourses().size()}) Want to show above div. jquery script. jQuery. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 6, 2022 in Education by JackTerrance
0 votes
    Course Results (${courseResponseList.getCourses().size()}) Want to show above div. jquery script. jQuery. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    I'm writing an app for Android in Xamarin Forms. I want to navigate the user from one page to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 14, 2022 in Education by JackTerrance
0 votes
    I'm writing an app for Android in Xamarin Forms. I want to navigate the user from one page to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 14, 2022 in Education by JackTerrance
0 votes
    I'm writing an app for Android in Xamarin Forms. I want to navigate the user from one page to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 9, 2022 in Education by JackTerrance
...