Submitting an ordered list to a server
<p>To teach myself Javascript, I'm trying to make a web page that gives users a list of items (e.g. foods), asks them to sort these foods from favorite to least favorite, and submit the data when they're done. Using jQuery sortables seems like a good way to do this. However, I'm not sure how the data submission should happen.</p>

<p>Here's what I'm thinking. Each of these food items would be in a div like this:</p>

<pre><code>&lt;div id="sortable"&gt;
    &lt;div id="1" class="foods"&gt;Pizza&lt;/div&gt;
    &lt;div id="2" class="foods"&gt;Sushi&lt;/div&gt;
    &lt;div id="3" class="foods"&gt;Taco&lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>When the user clicks a "submit" button, I want the order of these items to be determined, and for this ordering to be sent back to the server (by the way, I'm using Django on the server side). It seems I can determine the order of the items with a function like this:</p>

<pre><code>function getOrder()
{
    var foods = $(".foods");
    var ids = [];

    for(var x=0; x&lt;foods.length; x++)
    {
        ids.push(foods[x].id);
    }
    return ids;
}
</code></pre>

<p>However, I'm stuck on a couple of things:</p>

<ul>
<li>Where in my code would I call this function? I'm thinking it would be an onclick action when the user presses the submit button, but I'm not sure where the data the function returns would get passed.</li>
<li>What format would be the most appropriate for sending this ordering to the server (e.g JSON)?</li>
</ul>

<p>(I know this is a really basic question, but I have never made a web page with JavaScript before, so this area of programming is all new to me.)</p>
