Skip to content
Advertisement

Color,Price, and Size Filter In PHP Codeigniter And Ajax

Section 1

I have an issue in ” Displaying 1 – 5 of 10 records “. I have a piece of code which works only on first page, when i click on second page then it show the same result ” Displaying 1 – 5 of 10 records ” Instead of ” Displaying 10 of 10 records “.

Code In Controller

JavaScript

I don’t know whats wrong with it, I have tried other code which I find from different websites, but they are not working properly.

Section 2

I have a filter section, where user can filter product by Size, Color and Price, How to achieve this section?

My main/ Index Controller

JavaScript

My Model

JavaScript

How I can get the Filter section?

UPDATE 1

Section 1 issue has been fixed by replacing those two lines

JavaScript

TO

JavaScript

Update 2

I somehow did the filter section but now I am stuck in the ajax issue. Issue is that When color or size checkbox is empty then it throw error of foreach loop. I only need to control the empty or null section, like if the checkbox is unchecked then it will not send / post the value to the controller…

My Ajax Code is

JavaScript

I have tried many check like, undefined, or =='' or data.length <-1 etc. The data.length will did some check but i am not able to check the variable separately like, there are two variable I am send in data: color,size How can I check the variable separately like: if(data.color.length < 0 ) .

Advertisement

Answer

Answered is Here, All the details and code are posted in the mentioned link question.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement