Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    May 2007
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    jquery drag and drop from ASP to PHP please

    HI I am working on a new drag and drop in jquery I have found a perfect example code to work with however it uses ASP and I am a PHP guy

    Could someone who understands javasscript better change this code to send variables to a PHP file and tell me which variables to catch at the PHP end please

    Code:
    <script type="text/javascript">
    		    $("#gallery").dragsort({ dragSelector: "li div", dragEnd: saveOrder });
    
    		    function saveOrder() {
    		        var serialStr = "";
    		        $("#gallery li").each(function(i, elm) { serialStr += (i > 0 ? "|" : "") + $(elm).attr("itemID"); });
    		        $.ajax({ url: "example.aspx/SaveListOrder", data: '{"ids":"' + serialStr + '"}', dataType: "json", type: "POST", contentType: "application/json; charset=utf-8" });
    		    };
    	    </script>

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    Change it to point at a php file and it posts back ids.

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    New Coder
    Join Date
    May 2007
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <script type="text/javascript">
    		    $("#gallery").dragsort({ dragSelector: "li div", dragEnd: saveOrder });
    
    		    function saveOrder() {
    		        var serialStr = "";
    		        $("#gallery li").each(function(i, elm) { serialStr += (i > 0 ? "|" : "") + $(elm).attr("itemID"); });
    		        $.ajax({ url: "test.php?SaveListOrder", data: '{"ids":"' + serialStr + '"}', dataType: "json", type: "POST", contentType: "application/json; charset=utf-8" });
    		    };
    	    </script>

    I tried this and tried to catch any of these variables with get and post

    on test.php

    I try to catch any of these
    $_GET['SaveListOrder'];
    $_POST['SaveListOrder'];
    $_GET['ids'];
    $_POST['ids'];
    $_GET['data'];
    $_POST['data'];

    and none of those return any value though
    Last edited by jasondavis; 07-22-2009 at 05:27 PM.

  • #4
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    This is flat out wrong

    Code:
     data: '{"ids":"' + serialStr + '"}',
    it should be

    Code:
     data: {"ids": serialStr },
    if you want to send up multiple things

    Code:
     data: {"ids": serialStr, "foo" : "bar", "cheese": "whocut" },
    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •