CodeIgniter Forums

Full Version: Codeigniter Pagination with AJAX JQuery on XAMPP
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello to all of you as premise I say I'm very basic with Codeigniter

hopefully some Ci expert could hint what is wrong with this

this is Ci 3.1.10

I suspect my issue is matter of a wrong configuration in some file Confused


This Codeigniter pagination with ajax is running localhost on xampp

Here it is the code of this  really simple experiment,
https://itsolutionstuff.com/post/codeign...ample.html

mean a short tutorial
just matter of db creation
one controller using the codeigniter pagination library
and one view with jquery ajax at bottom


Well

the codeigniter folder has been renamed ci-pag
it is in
Code:
http://localhost/ci-pag
and pointing to there I have the standard welcome controller with CI welcome message

I have created the test db as in the tutorial using the provided query and filled in some data

briefly copied and pasted the provided controller and view with obviously the same names

configured codeigniter as ususal (for my xampp experiments) mean
- created .htaccess
- added the rewrite stuff for index.php removal
- changed the config.php to remove the index.php and set the base path to http://localhost/ci-pag/

THE ISSUE
when I point to
Code:
http://localhost/ci-pag/post
it does show only the header of the page but for the rest nothing  Sad

you can see the screenshot here No table just header


also

can you kindly hint how to approach some debug in a case such the current one? Thank you for this too if any

Thank you
Cor
Hi, in case you didnt make any other errors in controller,  check the ajax call in your view:
kdkfkk
PHP Code:
function loadPagination(pagno){
 
      $.ajax({
 
        url'/post/loadRecord/'+pagno,
 
        type'get' 

The url will be your problem. Try it with a full url:
url : 'http://localhost/ci-pag/post/loadRecord/'+pagno
(also it is a good idea to open the url directly). 
If it works check Codeigniter constants for get your CI urls in all cases.
What is that snippet above? Is that some javascript code communicating with a CI controller called Post with a function in it called loadRecord? For debugging such a thing I use two debuggers; one of the javascript side (I use the Chrome debugger) and one on CI/PHP side (aka server) I use phpStorm which uses xDebug. Hope that helps.
@lpeter

hello!

"The url will be your problem. Try it with a full url:
url : 'http://localhost/ci-pag/post/loadRecord/'+pagno
(also it is a good idea to open the url directly)."

yes that was the issue, now it works.

But ...

one more kind hint

The situation is

now I develop locally my experiment and one day I move it to a real hosting service

If now I tweak this file and maybe many more

It will be an issue to modify them back

So the kind/tip hint request is

- how to manage this with some sort of automatism?

is that matter of the constants you mention?

If yes, kindly, which one do you mean?

maybe the $config['base_url'] = 'http://localhost/ci-pag/'; in the config.php

or someone to add into the constants.php file?

or really I should leave that

url : 'http://localhost/ci-pag/post/loadRecord/'+pagno

and do the same in all the views files and later modify all of them (either I suppose the solution will be much smarter)

Thank you
Cor


@richb201
Thank you for replying

yes that is a piece of javascript JQuery related

May I kindly ask you if you mean the console viewer in the Chrome browser or something else? ( Please understand that I'm trying to dive into some advanced javascript and php programming instead than my old little php procedural experience, so thank you for hinting ).

About debuggin I've installed composer and with composer, I'm going to install whoops. Do you think it could be good as well as PHP debugger? Or the one you mentioned has something dedicated to CodeIgniter?
I ask that because I don't own a PHPStorm license

Instead I was using SublimeText and now I'm experimenting with a little of surprise with Visual Code Studio which is an unexpected free IDE program from Microsoft ( are they becoming philanthropists !?!?!? Angel )

Thank you for some advices
Cor
(02-10-2019, 12:40 PM)lpeter Wrote: [ -> ]Hi, in case you didnt make any other errors in controller,  check the ajax call in your view:
kdkfkk
PHP Code:
function loadPagination(pagno){
 
      $.ajax({
 
        url'/post/loadRecord/'+pagno,
 
        type'get' 

The url will be your problem. Try it with a full url:
url : 'http://localhost/ci-pag/post/loadRecord/'+pagno
(also it is a good idea to open the url directly). 
If it works check Codeigniter constants for get your CI urls in all cases.

Hello I have replied you above :-)

and here I kindly ask you

how can be managed the "Codeigniter constants for get my CI urls in all cases" ?

Thank you