Hi paul,

I can see at least one problem at the definition of the AJAX request.
You don't have any callback to treat the response.
You should have something like :

        new Ajax.Request("http://127.0.0.1/";, {
            method: "post",
            parameters: { data: Sortable.serialize("group1") },
!           onComplete:function(response){
!                  //Do what you need to do with the response
!           }
        });

I'm not a python coder, so I could say a bug mistake, but in the
python code, I see a "self.send_response(301) " and in that case, I
didn't know how AJAX request is handle?

To debug you're problem:
1- verify in firebug (or else) what is the return of the AJAX.REQUEST
(text/json/...).
2- If the 301 HTML code breaks the request, temporarly suppress it.
3- Verify that the callback function in the ajax.request is called
(just fill this function with an alert).

I hope it help you, if the problem is still here after the change,
just update the post, I can see what I can do for you this evening
(french time).

--
david


On 11 fév, 11:00, "Alex Mcauley" <[email protected]>
wrote:
> use firefox and firebug and see whats getting posted in the console log ..
> it should hell you to understand if Javascript is sending the data or not
>
> ----- Original Message -----
> From: "Paul" <[email protected]>
> To: "Prototype & script.aculo.us" <[email protected]>
> Sent: Wednesday, February 11, 2009 12:53 AM
> Subject: [Proto-Scripty] AJAX
>
> > Hi,
> > I'm fairly new to AJAX, and I'm trying to send it to my Python server
> > for the project that I'm doing, after doing a Sortable.serialize, but
> > I'm getting no data at the other end - the problem being I'm not sure
> > if it is the Python or the javascript which is causing the problem, so
> > I was wondering if people would be able to check my javascript?
> > I've got:
> > <SCRIPT type="text/javascript">
> > // <![CDATA[
> > Sortable.create('group1',{tag:'div',dropOnEmpty: true, containment:
> > sections,only:'lineitem',onUpdate:function() {
> >        new Ajax.Request("http://127.0.0.1/";, {
> >            method: "post",
> >            parameters: { data: Sortable.serialize("group1") }
> >        });
> >    }
> > });
> > Sortable.create('group2',{tag:'div',dropOnEmpty: true, containment:
> > sections,only:'lineitem',onUpdate:function(){alert('change2')}});
> > Sortable.create('group3',{tag:'div',dropOnEmpty: true, containment:
> > sections,only:'lineitem',onUpdate:function(){alert('change3')}});
> > Sortable.create('page',{tag:'div',only:'section',handle:'handle'});
> > // ]]>
> >  </SCRIPT>
> > The Sortable.serialize("group1") works when I put it as an alert so I
> > can rule that out so I can only think that I've constructed the AJAX
> > request wrong, but can't see how - I can see the POST going to the
> > server and can see an object appearing, but as far as I can tell it's
> > empty. If anyone's interested the Python code is:
> >    def do_POST(self):
> >            global rootnode
> >            ctype, pdict = cgi.parse_header(self.headers.getheader
> > ('content-type'))
> >            if ctype == 'multipart/form-data':
> >                query=cgi.parse_multipart(self.rfile, pdict)
> >                print(cgi.parse_header(self.headers.getheader('content-
> > type')))
>
> >                self.send_response(301)
>
> >                self.end_headers()
> >                print(query.get('data'))
> >                h = codecs.open ("log.txt", "a", encoding="utf8")
> >                h.write("test")
> >                h.close()
>
> >                print(query.get('random'))
> >                self.wfile.write(query.get('random'));
>
> >            elif ctype == 'application/x-www-form-urlencoded':
> >                print(cgi.parse_header(self.headers.getheader('content-
> > type')))
> >                data = self.rfile
> >                print(data.data)
> > Thank you for any help, I really appreciate it as I am totally stumped
> > Paul
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to