Many thanks folks!
I'll try use this here.
Marcus

On 26 jan, 03:45, Uwe Feldtmann <[EMAIL PROTECTED]> wrote:
> Markm wrote:
> > I am just begining here ... do you mind if I see that your complete (I
> > mean your controller and defs) code? For eg, I did not understand this
> > piece of code:
>
> > I'm fighting with the same problem and it'll be very useful if I could
> > learn with you!Hi Markus.
>
> I see that Bob Ippolito has already explained the function() { ... }
> definition  - thanks Bob.
>
> Most of the code I used was only to test out sending data back and forth
> between the server and the browser withoutusinghtml forms and would be
> more confusing than it's worth so I'll sum up what I've learned from
> experimentation and with the patient assistance of others on this list
> (thank you all).  If anything here is incorrect or could be done better
> then please let us all know.
>
> Simple rules I read somewhere:-
> Use GET if the data you are sending to the server is less than 512 bytes
> and can be sent on the url.
> Use the POST method if the data is more than 512 bytes or needs to be
> more secure.
>
> ---------------
>
> Sending from the browserusingGET:-
>
> function toServerByGET(url, fct) {
>     xmlhttp = new XMLHttpRequest();
>
>     xmlhttp.onreadystatechange = function() {
>         if ( xmlhttp.readyState==4 ) {
>            fct( xmlhttp.responseText );
>         }
>     };
>
>     xmlhttp.open("GET",url);
>     xmlhttp.send(null);
>
> }and is called like this
>
> urlAndData = "/controllerName/methodName/?parm1=" + value1 +
> "&amp;parm2=" + value2;
> toServer( urlAndData, responseHandler )
>
> ---------------
>
> Sending from the browserusingPOST:-
>
> function toServerByPOST( url, data, fct ) {
>    xmlhttp = new XMLHttpRequest();
>
>    xmlhttp.open( "POST", url, true );
>
>    // note setRequestHeader must appear after .open and is used
>    // to encode the data as though it came from a form (thanks Robert)
>    xmlhttp.setRequestHeader( "Content-Type",
> "application/x-www-form-urlencoded" );
>
>    xmlhttp.onreadystatechange = function() {
>         if ( xmlhttp.readyState==4 ) {
>             fct( xmlhttp.responseText );
>         }
>    }
>
>    xmlhttp.send( data );
>
> };and is called like this
>
> var data = {
>     id: 1,
>     parm1: "value1"
>     parm2: "value2"}toServerByPOST( "/controllerName/methodName", data, 
> responseHandler );
>
> ---------------
>
> The method in the controller is the same in both instances:-
>
> class ControllerNameController(BaseController):
>
>     def methodName(self):
>         value1 = request.params['parm1']
>         value2 = request.params['parm2']
>
>         return Response( "responseData" )
> 
> ---------------
> 
> Hope this helps in some way.
> 
> Uwe.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to