Answer the question
In order to leave comments, you need to log in
Loading data with AJAX in CodeIgniter?
Hello.
I need help, I searched the Internet and did not find what exactly I need.
Articles are loaded on my site, There are a lot of them, so I don’t know how to do this:
EXAMPLE:
The last 10 articles are loaded. At the end (at the bottom) there is a button, when clicked, 10 more articles should be loaded, etc.
PS
They will have to be loaded using AJAX.
I am using CodeIgniter.
Thank you all in advance...
Answer the question
In order to leave comments, you need to log in
I'll tell you how I did it myself:
An ajax request is sent when you click on a button with one parameter: the id of the last article. It can be stored as data-id for each article and retrieved, for example, as last-child.
On the server:
Method pulling articles from the database, where the request is by type
Then you render the code itself, I did it on Laravel, there is a built-in function for this. I don't know if there is something similar in CI. In extreme cases, you can simply form a string:
$text= '';
foreach($articles as $article) {
$text.="<a href='/articles/$article['id']'>$article['title']</a>"
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question