Jump to content

Recommended Posts

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

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 }
			});	

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.