Having a problem with an AJAX function that I need help solving:
- PAGE A represents the main page.
- PAGE X represents the content loaded via AJAX.
- RES A represents the results from PAGE A.
- RES B represents the new results loaded via AJAX.
PAGE A initially contains 20 results, and each result can be removed to load a new result from PAGE X using AJAX.
For example:
User is on PAGE A: --> PAGE A initializes js "click" functions. --> Results are displayed as RES A (20x).
When user removes a result from RES A (1x), AJAX loads a new result RES B (1x):
User still remains on PAGE A. --> PAGE X is loaded with js "click" functions. --> Result becomes RES B (1x)
To add click functions to RES B, I must reload a lighter JS which ends up multiplying the functions of RES A.
Therefore, when user removes results from RES A (e.g. 5 results removed), RES B result gets multiplied (the user receives multiple instances of the same result instead of one).
Do you understand the issue? In short, the AJAX request multiplies RES B instead of sticking to one request. Any suggestions on how to ensure RES B remains only 1 instance?
Thank you!