Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9244645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:05:14+00:00 2026-06-18T09:05:14+00:00

I am working on a jQuery sortable. I pull information from my database to

  • 0

I am working on a jQuery sortable. I pull information from my database to populate each orderable element and then repost the new order back to my data base. However I cannot figure out how to take the variable that I define in my serialize jQuery and enter it into my AJAX function in the data: area.

Here is my code:

$(document).ready(function() 
{              
    $('#social_list').sortable(
    { 
        update: function() 
        {
            var order = $('#social_list').sortable('serialize');
            alert(order);
        }                         
    });
});

$.ajax(
{
    url: 'save_items_order.php',
    data: ?,
    type: '$_POST', 
    success: function(msg)
    {
        alert(msg);
    }
});

So I want to take the string that var order creates and pass it into the ajax so data: = var order string

I tried data: $(‘#social_list’).sortable(‘serialize’), everything seemed to work it just doesn’t seem to update my table

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T09:05:16+00:00Added an answer on June 18, 2026 at 9:05 am

    Simplest solution is to make a global

    $(document).ready(function() {
        $('#social_list').sortable({
            update: function() {
                // global. you could just omit var, but I find this clearer
                window.order = $('#social_list').sortable('serialize');
            }
        });
    });
    
    $.ajax({
        url: 'save_items_order.php',
        data: window.order, /* ...rest of code */
    });
    

    But I’m sure you know globals are bad, you can at least contain them to your namespace,

    var myNs = {};
    $(document).ready(function() {
        $('#social_list').sortable({
            update: function() {
                myNs.order = $('#social_list').sortable('serialize');
            }
        });
    });
    
    $.ajax({
        url: 'save_items_order.php',
        data: myNs.order /* ... rest of code */
    });
    

    or re-organize your code so they can share variables.

    $(document).ready(function() {
        var order;
        $('#social_list').sortable({
            update: function() {
                order = $('#social_list').sortable('serialize');
            }
        });
        $('#myButton').click(function(){
            $.ajax({
                url: 'save_items_order.php',
                data: order, /* ... rest of code */
            });
        });
    });
    

    Note that for this case, you could just do the following

    $.ajax({
        url: 'save_items_order.php',
        data: $('#social_list').sortable('serialize') /* ... rest of code */
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working with the jQuery Sortable plugin to drag and drop images from one
I'm working with a demo of two sortable jquery lists... but have a problem
I am working with jQuery UI Sortable plugin, and applying it to a table.
I am using this and it's working perfectly on the browser http://docs.jquery.com/UI/Sortable Now I
I have been working with JQuery sortable grids, and have run into a strange
Working with jQuery UI sortable to move around a list of items, and trying
I have been working with jquery-ui's sortable demo for a while. On looking closely,
I am implemented a jQuery UI sortable element. Here is my code: $(function() {
I am working with the jQuery UI Sortable plugin and everything works as expected
I've got an Ajax call from the stop event of my jQuery UI sortable

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.