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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:04:00+00:00 2026-05-22T18:04:00+00:00

I really have problems with the jQuery drag and drop. So let me explain

  • 0

I really have problems with the jQuery drag and drop. So let me explain the situation a bit.

What I want to achieve is the following: when you drag one of the teardrops on the timeline, the id from the div and the id from the item it’s dropped on, should be stored in my db immediately after the drop.

I managed to do that with ajax, here’s the code:

$('#dropzone ul li').droppable({
  drop: function(event, ui) {
        var day = $(".confirmday").val();
        var $drag = $(ui.draggable),
        var $drop = $(this);

        var drag = $drag.attr('id');
        var drop = $drop.attr('id');

        console.log(drag);

        if(drag == 'drag1')
        {
            drag = 'Medicijnen';
            werkwoord = ' ingenomen om ';
        }
        else if(drag == 'drag2')
        {
            drag = 'Snack';
            werkwoord = ' gegeten om ';
        }
        else if(drag == 'drag3')
        {
            drag = 'Frisdrank';
            werkwoord = ' gedronken om ';
        }
        else if(drag == 'drag4')
        {
            drag = 'Thee';
            werkwoord = ' gedronken om ';
        }
        else if(drag == 'drag5')
        {
            drag = 'Koffie';
            werkwoord = ' gedronken om ';
        }
        else if(drag == 'drag6')
        {
            drag = 'Alcohol';
            werkwoord = ' gedronken om ';
        }

        $.post("ajax/save.php", { 
                drag: drag,
                drop: drop,
                userid: <?php echo $_SESSION['id']; ?>,
                day: day},
                function(data) 
                {
                });
        return false;
    },
});

But when I do that, the dragged item (or the clone of that item) just disappears. I don’t know why, because the page doesn’t refresh. The new item just won’t store.

The other option I tried was to put the dragged item’s ID and the dropped on item ID in a text box and to save that every time something is dropped. But that won’t work as well.

I really hope someone can help me!
Thanks in advance.

enter image description here

  • 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-22T18:04:01+00:00Added an answer on May 22, 2026 at 6:04 pm

    You are returning false at the end of the drop callback handler.

    This will tell the droppable that the draggable was invalid and will then discard it. If you remove return altogether it should work.

    I took the liberty to optimize your code, I hope you don’t mind 😉

    $('#dropzone ul li').droppable({
        drop: function(event, ui) {
            var day = $(".confirmday").val(),
                drag, werkwoord;
    
            switch (ui.draggable[0].id) {
                case "drag1":
                    drag = 'Medicijnen';
                    werkwoord = ' ingenomen om ';
                break;
    
                case "drag2":
                    drag = 'Snack';
                    werkwoord = ' gegeten om ';
                break;
    
                case "drag3":
                    drag = 'Frisdrank';
                    werkwoord = ' gedronken om ';
                break;
    
                case "drag4":
                    drag = 'Thee';
                    werkwoord = ' gedronken om ';
                break;
    
                case "drag5":
                    drag = 'Koffie';
                    werkwoord = ' gedronken om ';
                break;
    
                case "drag6":
                    drag = 'Alcohol';
                    werkwoord = ' gedronken om ';
                break;
    
                default:
                    return false;
                break;
            }
    
            $.post("ajax/save.php",
                { 
                    drag: ui.draggable[0].id,
                    drop: this.id,
                    userid: <?php echo $_SESSION['id']; ?>,
                    day: day
                },
                function(data){}
            );
        },
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a little problem about using jQuery (I really do not know jQuery
I really have big problems with importing an extern C-Library to my existing C++-Project.
Have you any problems using it on high concurrency environment? It's really works as
Well, I have a really small problem. How can I access an ASP.NET Drop
I have a jQuery-Script to accomplish the following tasks: if a gridview in my
I have the weirdest of problems. I have a jQuery function that animates the
I have a jQuery problem, and I've really tried everything I know (i am
I'm using the Draggable/Droppable functionality of Jquery to allow drag-and-drop from a TreeView to
I'm having some problems with jquery and I really hope someone out there can
I'm sure this is really simple, but I'm having problems with it. I have

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.