Jonathon,
Here is the code in my qooxdoo app that instantiates the grfind.HttpRequest
below. After building the request, I add listeners and then actually do
the send(). I have been having trouble with the POST for a long time not
working, but have taken a close look at it over the last few days and I
don't see what I am doing wrong. It is just hit or miss whether my request
is going to send valid json ( a string containing valid json) to the server.
The json is being built properly on the client.
My data has a single key 'data' and a single value for that key, the
stringified dictionary. I know that it seems strange that a semicolon
causes corrupt results, and maybe other things do also, but I have been
having erratic results using POST for a long time and either I am doing
something wrong or something is broken, and I don't know which.
It seems to boil down to the fact that my data gets corrupted if there is a
semicolon anywhere in any of my dictionary values.
I will triple check this morning to make absolutely sure that the client is
in fact sending valid json, but I am sure that it is.
Thanks.
tom
Here is the way I call the following class
... assign variables here
var data = { 'session-key' :
this.getApp().getSessionKey(),
'store-type' : this.getStoreType(),
'online-status' : onlineStatus,
'store-email' : storeEmail,
'store-name' : storeName,
'store-policies' : storePolicies,
'store-about-info' : storeAboutInfo
};
var req = new grfind.HttpRequest(url, "POST",
"application/json", 2000, data);
//
*****************************************************************************
// * grfind.HttpRequest
*
//
*****************************************************************************
qx.Class.define("grfind.HttpRequest",
{
extend : qx.core.Object,
//************************************************************************
// CONSTRUCTION
*
//************************************************************************
construct : function( url, method, mime, timeout, data )
{
this.base(arguments);
//
// app
//
this.setApp( qx.core.Init.getApplication() );
//
// build request
//
switch ( method ) {
case "GET" : {
if ( url && method && mime && timeout ) {
try {
req = new qx.io2.HttpRequest();
req.setUrl( url );
req.setMethod( method );
req.setMime( mime );
req.setTimeout( timeout )
return req;
} catch(e) {
this.getApp().userMessage("HttpRequest - could
not assign parameters");
return null;
}
} else {
this.getApp().userMessage("HttpRequest - could not
get valid arguments");
return null;
}
};
break;
case "POST" : {
if ( url && method && mime && timeout && data ) {
try {
req = new qx.io2.HttpRequest();
//req.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded");
req.setUrl( url );
req.setMethod( method );
req.setMime( mime );
req.setTimeout( timeout )
try {
data = qx.util.Json.stringify( data );
req.setData( "data=" + data );
} catch(e) {
this.getApp().userMessage("HttpRequest -
could not stringify data");
return null;
}
return req;
} catch(e) {
this.getApp().userMessage("HttpRequest - could
not assign parameters");
return null;
}
} else {
this.getApp().userMessage("HttpRequest - could not
get valid arguments");
return null;
}
};
break;
default: {
this.getApp().userMessage("HttpRequest - could not get
valid method");
return null;
};
};
},
/*
*****************************************************************************
PROPERTIES
*****************************************************************************
*/
properties :
{
app :
{
init : null
}
}
});
// EOF
Jonathan Weiß-2 wrote:
>
> Hello Tom,
>
>
> I will try to verify this. In advance I have a question: if I read
> your server result correctly you get returned an object with the key
> data and a long string:
>
> {
> data : "(a long string containing )"
> }
>
> Shouldn't it look more like
>
> {
> data :
> {
> "session-key":"1252035241-sk",
> "store-type":"books",
> "online-status":"online",
> "store-email":"[email protected]",
> "store-name":"featherbottoms",
> "store-policies":"now is the time;",
> "store-about-info":"About Featherbottoms"
> }
> }
>
> ?
>
> Kind regards
> Jonathan
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
> 30-Day
> trial. Simplify your report design, integration and deployment - and focus
> on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now. http://p.sf.net/sfu/bobj-july
> _______________________________________________
> qooxdoo-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>
>
--
View this message in context:
http://www.nabble.com/qx.io2.HttpRequest-urlencoded-problem-POST-8.2-tp25287879p25297787.html
Sent from the qooxdoo-devel mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel