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 7409659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:06:58+00:00 2026-05-29T06:06:58+00:00

Being new to JQuery and trying to understand all the posts about different ways

  • 0

Being new to JQuery and trying to understand all the posts about different ways of posting data I still am at a loss as to why my function doesn’t work. Any help would be welcome as I’ve spent days trying to get this to work.

I have a sortable ul list:

            <ul class="gallery" id ="gallery">
                <li id="item_59"><a href="/images/pages/apartamentos/155/image115_7.jpg" title=""><img src="/images/pages/apartamentos/155/image115_7.jpg"  alt="" /></a></li>
                <li id="item_61"><a href="/images/pages/apartamentos/155/image115_6.jpg" title=""><img src="/images/pages/apartamentos/155/image115_6.jpg"  alt="" /></a></li>
                <li id="item_62"><a href="/images/pages/apartamentos/155/image115_3.jpg" title=""><img src="/images/pages/apartamentos/155/image115_3.jpg"  alt="" /></a></li>
                <li id="item_63"><a href="/images/pages/apartamentos/155/image115_5.jpg" title=""><img src="/images/pages/apartamentos/155/image115_5.jpg"  alt="" /></a></li>
                <li id="item_64"><a href="/images/pages/apartamentos/155/image115_2.jpg" title=""><img src="/images/pages/apartamentos/155/image115_2.jpg"  alt="" /></a></li>
                <li id="item_65"><a href="/images/pages/apartamentos/155/image115_1.jpg" title=""><img src="/images/pages/apartamentos/155/image115_1.jpg"  alt="" /></a></li>
                <li id="item_66"><a href="/images/pages/apartamentos/155/image115_4.jpg" title=""><img src="/images/pages/apartamentos/155/image115_4.jpg"  alt="" /></a></li>
            </ul>

Then in the same doc I have this Jquery:

   <script type="text/javascript">

$(document).ready(function() {


        $(function(){
        $("#gallery").sortable({stop:function(event, ui) {

        $.ajax({
        type: "GET",
        url: "image_order.php",
        data: $("#gallery").sortable("serialize"),

                    success: function(data) {
                        if (data) {
                            $('#msg').html('Success');
                        } 
                    },
                    error: function () {
                        $('#msg').html('Failed');
                    }

                })
                }
            });

    }
}


</script>

Then I have a image_order.php:

 foreach ($_GET['item'] as $position => $item) {
$query_edit = "UPDATE `image_order` SET `position` = $position WHERE `id` = $item";
mysql_query($query_edit, $ith) or die(mysql_error());
$sql[] = "UPDATE `image_order` SET `position` = $position WHERE `id` = $item";
}

echo json_encode($sql);

Which when you manualy enter
image_order.php?item[]=1&item[]=2&item[]=3&item[]=4
returns:

["UPDATE `image_order` SET `position` = 0 WHERE `id` = 1","UPDATE `image_order` SET `position` = 1 WHERE `id` = 2","UPDATE `image_order` SET `position` = 2 WHERE `id` = 3","UPDATE `image_order` SET `position` = 3 WHERE `id` = 4"] 

I have a similar json function which works on this page and I see the url being called in the console but not this one.

I’ve also tried $(“ul.gallery”).sortable({stop:function(event, ui) {… but that doesn’t work either.

Help would be great…please…

  • 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-05-29T06:06:59+00:00Added an answer on May 29, 2026 at 6:06 am

    I had to bind the sortstop event (RTM):

    http://jqueryui.com/demos/sortable/#event-stop

      $( "ul.gallery" ).bind( "sortstop", function(event, ui) {
            $.ajax({
            type: "GET",
            url: "image_order.php",
            data: $("ul.gallery").sortable("serialize"),
    
                        success: function(data) {
                            if (data) {
                                $('#msg').html('Success');
                            } 
                        },
                        error: function () {
                            $('#msg').html('Failed');
                        }
    
                    })
    
                });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to dynamically filter out content using checkboxes and jquery. Being new
Being new to Cocoa, and probably not knowing all of the potential classes available
I'm using the jQuery Plugin jqModal . New to it, so i'm still learning
I'm new to jQuery and Javascript. I'm trying to make a button that I
I'm trying to pass an array from a jQuery function to my controller. The
i think i am not going about this quite right, being very new to
Greetings, Being new to jQuery's syntax, I find myself being a bit thrown off
I'm fairly new with jQuery, and I'm trying to call two functions on successful
Being new to test based development, this question has been bugging me. How much
being new to WPF this is a complex problem for me. What i want

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.