Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery, need help with 'sortreceive' ajax call and POST vars
    primarykey
    data
    text
    <p>I have a dilemma that just seems beyond my abilities at the moment!</p> <p>I have a group of connected sortables using the class 'biglist'. </p> <p>What I want to do is bind #biglist 's sortreceive callback (which is made whenever a list receives an element from another) to take the 'boxnum' value of the element (which signifies which list its coming from) and perform an UPDATE query changing the id's boxnum value from say 5(list it came from) to 7 (list its been dragged to) so that the state persists.</p> <p>So the exchange would happen like so (roughly)</p> <pre><code>$( "#biglist" ).bind( "sortreceive", function(event, ui) { ajax call to boxchange.php create vars to represent elements 'boxnum' value and 'box moved to' value }); </code></pre> <p>Then inside boxchange.php -></p> <pre><code> $id = $_POST['id'] $box = $_POST['boxnum'] -&gt;update query SET boxid to new boxid WHERE id = posted ID of element </code></pre> <p>I hope this makes sense. It seems like a pretty slick way to make my program work! Any help is greatly appreciated.</p> <pre><code>EDIT: </code></pre> <p>Just cleaned up the function to see if there are any changes that need to be made to it (which I know there are, because it looks sloppy) This function would need to be copied/altered for each sortable separately but it'd totally make the program work at least!</p> <pre><code>function ReceiveTwo() { $('#sortable2').bind('sortreceive', function(event, ui) { boxnum = $(this).attr('boxnum'); id = $(this).attr('id'); $.ajax ({ url: "boxchange.php", type: "POST", data: boxnum, id, success : function(feedback) { $('#data').html(feedback) } }) }); $('#sortable2').sortable("refresh"); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload