|
List Info
Thread: xmlhttprequest + json + pylons
|
|
| xmlhttprequest + json + pylons |
  United States |
2007-11-06 03:35:52 |
Hi
JSONRequest = {
post: function( url, data, callback, timeout ) {
xhr = new XMLHttpRequest();
xhr.open("POST", url, true);
xhr.setRequestHeader( "Content-Type",
"application/x-www-form-
urlencoded" );
if (callback) {
xhr.onreadystatechange = function() {
if( xhr.readyState==4 ) {
//alert( xhr.responseText );
callback( xhr.responseText );
}
}
}
if ( data ) {
xhr.send( data );
} else {
xhr.send( null );
}
},
get: function(url, callback) {
alert( 'in JSONRequest.get();' );
}
};
using above code(js) I send the
data(login={username:"python",password:"pylon
s") to pylons.
... pylons controller...
print request.params.keys()
print request.params.items()
print request.params.values()
I am getting flowing output...
['login']
[('login', u'{username:"python", password:"
[u'{username:"python",
password:"pylons"}']
How can I get the username & password value ?
Thanks
Madhu Alagu
--~--~---------~--~----~------------~-------~--~----~
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
pylons-discuss-unsubscribe googlegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: xmlhttprequest + json + pylons |
  United States |
2007-11-06 08:04:44 |
Madhu, It looks like the data being sent via xhr is in an
improper
format. According to the javascript you provided, data
should be a
urlencoded string. If you send the string
'username=python&password=pylons' as data, you should be
able to
access the value of username via request.params['username'],
and the
value of password via request.params['password']
On Nov 6, 3:35 am, Alagu Madhu <alma... gmail.com> wrote:
> Hi
>
> JSONRequest = {
> post: function( url, data, callback, timeout ) {
> xhr = new XMLHttpRequest();
> xhr.open("POST", url, true);
> xhr.setRequestHeader( "Content-Type",
"application/x-www-form-
> urlencoded" );
> if (callback) {
> xhr.onreadystatechange = function() {
> if( xhr.readyState==4 ) {
> //alert( xhr.responseText );
> callback( xhr.responseText );
> }
> }
> }
> if ( data ) {
> xhr.send( data );
> } else {
> xhr.send( null );
> }
> },
> get: function(url, callback) {
> alert( 'in JSONRequest.get();' );
> }
>
> };
>
> using above code(js) I send the
>
data(login={username:"python",password:"pylon
s") to pylons.
>
> ... pylons controller...
>
> print request.params.keys()
> print request.params.items()
> print request.params.values()
>
> I am getting flowing output...
>
> ['login']
> [('login', u'{username:"python",
password:"
> [u'{username:"python",
password:"pylons"}']
>
> How can I get the username & password value ?
>
> Thanks
>
> Madhu Alagu
--~--~---------~--~----~------------~-------~--~----~
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
pylons-discuss-unsubscribe googlegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: xmlhttprequest + json + pylons |
  United States |
2007-11-06 09:43:57 |
if I like to send the json format,I should change
setRequestHeader
or ?
On Nov 6, 5:04 pm, kwilliams <kurt.r.willi... gmail.com> wrote:
> Madhu, It looks like the data being sent via xhr is
in an improper
> format. According to the javascript you provided, data
should be a
> urlencoded string. If you send the string
> 'username=python&password=pylons' as data, you
should be able to
> access the value of username via
request.params['username'], and the
> value of password via request.params['password']
>
> On Nov 6, 3:35 am, Alagu Madhu <alma... gmail.com> wrote:
>
> > Hi
>
> > JSONRequest = {
> > post: function( url, data, callback, timeout )
{
> > xhr = new XMLHttpRequest();
> > xhr.open("POST", url, true);
> > xhr.setRequestHeader(
"Content-Type", "application/x-www-form-
> > urlencoded" );
> > if (callback) {
> > xhr.onreadystatechange = function() {
> > if( xhr.readyState==4 ) {
> > //alert( xhr.responseText );
> > callback( xhr.responseText );
> > }
> > }
> > }
> > if ( data ) {
> > xhr.send( data );
> > } else {
> > xhr.send( null );
> > }
> > },
> > get: function(url, callback) {
> > alert( 'in JSONRequest.get();' );
> > }
>
> > };
>
> > using above code(js) I send the
> >
data(login={username:"python",password:"pylon
s") to pylons.
>
> > ... pylons controller...
>
> > print request.params.keys()
> > print request.params.items()
> > print request.params.values()
>
> > I am getting flowing output...
>
> > ['login']
> > [('login', u'{username:"python",
password:"
> > [u'{username:"python",
password:"pylons"}']
>
> > How can I get the username & password value ?
>
> > Thanks
>
> > Madhu Alagu
--~--~---------~--~----~------------~-------~--~----~
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
pylons-discuss-unsubscribe googlegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
[1-3]
|
|