Cheezen Posted August 21, 2011 Share Posted August 21, 2011 Hi! I'll make myself short: I have a index.php where I send parameters to script.php using the following code: <script type="text/javascript"> //<![CDATA[ document.observe('dom:loaded', function() { var changeEffect; Sortable.create("selectedSetupTop", {containment: ['listStr', 'listAgi', 'listInt', 'selectedSetupTop', 'selectedSetupMid', 'selectedSetupBot', 'selectedSetupFor'], tag:'img', overlap:'vertical', constraint:false, dropOnEmpty: true, onChange: function(item) { var list = Sortable.options(item).element; $('changeNotification').update(Sortable.serialize(list).escapeHTML()); if(changeEffect) changeEffect.cancel(); changeEffect = new Effect.Highlight('changeNotification', {restoreColor:"transparent" }); }, onUpdate: function(list) { new Ajax.Request("script.php", { method: "post", onLoading: function(){$('activityIndicator').show(), $('activityIndicator2').hide()}, onLoaded: function(){$('activityIndicator').hide(), $('activityIndicator2').show()}, parameters: { data: Sortable.serialize(list), container: list.id } }); } }); }); // ]]> </script> The array I'm sending is called selectedSetupTop which is the name of a div. While at script.php I use Firebug to see if the data I want to send from index.php parses. It does, here is what the array selectedSetupTop looks like (in Firebug that is): selectedSetupTop[]=25&selectedSetupTop[]=1&selectedSetupTop[]=2 How do I print it on script.php? I'll use the array for a SQL query for your information. I've been googling for a while now and I guess json_encode() is the thing that should do it, but I don't know how to use it. If I use echo js_encode($selectedSetupTop) there is no output. I'd like to format to be in 1,2,3,4,5 but my real problem is to print it. By the way, what happens on index.php is that an element is dropped into a div (using drag'n'drop + sortable using scriptaculous and prototype) and all the ID:s in the container is sent to script.php. Tell me if you need a better explanation I attached the necessary parts of my index.php code. Thanks in advance!! Quote Link to comment https://forums.phpfreaks.com/topic/245325-printing-array-parsed-through-ajax-success/ Share on other sites More sharing options...
trq Posted August 21, 2011 Share Posted August 21, 2011 How do I print it on script.php? If your going to use it in a query what do you need to print it for? I'd like to format to be in 1,2,3,4,5 but my real problem is to print it. echo implode(',', $_GET['selectedSetupTop']); Quote Link to comment https://forums.phpfreaks.com/topic/245325-printing-array-parsed-through-ajax-success/#findComment-1260017 Share on other sites More sharing options...
Cheezen Posted August 21, 2011 Author Share Posted August 21, 2011 Thanks for the answer! Well, I thought it was a good start to print it to see if it really works. Unfortunately your code doesn't work =/ No output. Quote Link to comment https://forums.phpfreaks.com/topic/245325-printing-array-parsed-through-ajax-success/#findComment-1260135 Share on other sites More sharing options...
trq Posted August 21, 2011 Share Posted August 21, 2011 Take a look at: print_r($_GET); for debugging. Quote Link to comment https://forums.phpfreaks.com/topic/245325-printing-array-parsed-through-ajax-success/#findComment-1260330 Share on other sites More sharing options...
Cheezen Posted August 22, 2011 Author Share Posted August 22, 2011 Take a look at: print_r($_GET); for debugging. Hrm, it doesn't give me any output either. If I try to send a query string with the same function using this code I can get it, but I can't get the post data. new Ajax.Request("saveImageOrder.php?s=<?php echo $querySetup ?>", { method: "post", onLoading: function(){$('activityIndicator').show(), $('activityIndicator2').hide()}, onLoaded: function(){$('activityIndicator').hide(), $('activityIndicator2').show()}, parameters: { data: Sortable.serialize(list), container: list.id } }); Quote Link to comment https://forums.phpfreaks.com/topic/245325-printing-array-parsed-through-ajax-success/#findComment-1260490 Share on other sites More sharing options...
trq Posted August 22, 2011 Share Posted August 22, 2011 post data shows up in $_POST. Quote Link to comment https://forums.phpfreaks.com/topic/245325-printing-array-parsed-through-ajax-success/#findComment-1260707 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.