#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    204
    Rep Power
    2

    Update div with content from Ajax.


    Hi, i'm using Jquery draggable, when you drag an item in a div it get's added to the Database.. But now my question is, once it's added to the database.. The list has to refresh and show that it's added...

    Now.. what's the best practice to do this? Now the list get's called like this using php

    Code:
    <?php foreach($lijsten as $lijst) : ?>
    <div class="dropper" id="<?= $lijst['id'] ?>">
    	<p></p>
    </div>
    <?php endforeach ?>
    Should i update the list using a jquery function that calls the ajax to the list? And use that in the first place instead of loading it with PHP? Thanks, i'm really stuck in this logic
  2. #2
  3. A Not To Shabby Code Smurf
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2008
    Posts
    1,110
    Rep Power
    119
    If your re-ordering the <li> elements with the jQuery .css() API and your sending the updated data with the jQuery .ajax() API, to the update the list position, with your PHP/MySQL/Database; then you should have the effect you need. Because the <li> element's position would remain the same, on the current page and once the page reloads; the updated <li> positions will be applied (from your database) to the current page. You see what I am saying?

    Here is a pretty good tutorial about what you are trying to do; just encase you would like to see how someone has already accomplished this method: http://tutorialzine.com/2010/03/ajax...php-mysql-css/.

IMN logo majestic logo threadwatch logo seochat tools logo