Forums

AJAX incrementer updating to database (2 posts)

  1. daveycroqet
    Member
    Posted 1 year ago #

    After following the example here a href=http://codex.wordpress.org/AJAX_in_Plugins (specifically, the "Ajax on the Viewer-Facing Side" portion), I have run into some trouble.

    I have it successfully updating to a database, but I can only get it to do so once per page load. For example, I have 2 objects, each with point values. Object #1 has 10 points; object #2 has 0 points. I can click a button to raise or lower any of their points by 1. But if I click the same button again, my error-checking spits out an error which says that the database returned '0'. Here's a code snippet of the AJAX callback:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    I understand that in order to continue dynamically updating point values, I would need to read the newly input value from the database, and then write out the new values in $output and also make the buttons clickable again. This is where my issue occurs: When I run a FOR loop, it breaks the AJAX and will not update on the page anymore. Seeking any and all assitance please!

    If more code posting is required, I will happily oblige. Thanks in advance to anyone who tries to jump in. :D

  2. ambrosite
    Member
    Posted 1 year ago #

    I've built something similar on one of my WP sites. Perhaps if you repost your code using the pastebin as suggested, I could assist you.

Topic Closed

This topic has been closed to new replies.

About this Topic