I have a webpage with a link on it. You click on the link, and it generates a table inside of a <div> with AJAX. Along with the table, when this <div> loads it calls some javascript into play so that the user can up/down vote on items in the table. My problem is, if the user clicks that same link to regenerate the <div>, it reloads a SECOND javascript, so that clicking the upvote arrow once actually runs +1 twice. I don’t know if you’ll need to see any specific code, or if there is some general way to fix this, but here is a clearer picture of my file setup.
mainpage.php with link called “show table”
voting.js
getTable.php
*Click on “show table” on main page, getTable.php is called.
*getTable.php calls voting.js so that user can vote on items
*Click “show table” again and ANOTHER voting.js is called
*Now clicking upvote arrow passes through twice the +1 code.
What can a guy do?
You could include the voting.js on mainpage.php instead of getTable.php. It would be loaded once, but getTable could still use it.