This project is archived and is in readonly mode.

#491 ✓invalid
Oskar Krawczyk

Sending data as a string | object causes different results

Reported by Oskar Krawczyk | January 16th, 2011 @ 09:48 AM | in (closed)

Not sure if this behavior is intentional, but it sure looks like a bug to me:

Say we're doing a request:

new Request.JSONP({
    url: '',
    data: ''

This will send mail as test (notice the space instead of +)

The following works as expected (+ isn't replaced with a space):

new Request.JSONP({
    url: '',
    data: {
        mail: ''


Comments and changes to this ticket

  • Arian

    Arian January 16th, 2011 @ 10:56 AM

    • State changed from “new” to “open”
    • Tag changed from request.jsonp to querystring, request.jsonp
    • Milestone set to
    • Milestone order changed from “197538” to “0”

    I would say it is expected because in the first case you use a querystring, so you need to encode the string as a querystring, and because + will always be replaced by a space, that will happen here too.

    In the second case you send it as data and not as querystring so in that case the + is preserved.

    Notice that Request works the same way:

    If you create the querystring dynamically, you probably need to use the encodeURIComponent function first to encode it as a value for a querystring.

    In case someone else has another opinion, i'll leave it open for a while.

  • JacobThornton

    JacobThornton January 17th, 2011 @ 07:13 AM

    • State changed from “open” to “invalid”

    ++ to what arian said...

    objects and elements are called with toQueryString, which is responsible for properly encoding your data, while raw strings must be assumed to have already been encoded (so as not to double encode them).

    marking as invalid.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

The MooTools Extensions

People watching this ticket