PDA

View Full Version : jquery drag and drop from ASP to PHP please


jasondavis
07-22-2009, 02:34 AM
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


<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>

A1ien51
07-22-2009, 12:17 PM
Change it to point at a php file and it posts back ids.

Eric

jasondavis
07-22-2009, 05:16 PM
<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

A1ien51
07-23-2009, 04:21 PM
This is flat out wrong

data: '{"ids":"' + serialStr + '"}',

it should be

data: {"ids": serialStr },

if you want to send up multiple things

data: {"ids": serialStr, "foo" : "bar", "cheese": "whocut" },

Eric