Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange encoding of client.fields when accessing from api. #52

Closed
ghost opened this issue Jun 15, 2014 · 1 comment
Closed

Strange encoding of client.fields when accessing from api. #52

ghost opened this issue Jun 15, 2014 · 1 comment
Labels

Comments

@ghost
Copy link

ghost commented Jun 15, 2014

I'm trying to get POST data from client.fields property and getting such string which cannot be parsed with JSON.parse:
{ '{"0":{"value":"alega","path":"services.list.1.0.header"},"1":{"value":"agafonov ': '',
'nbsp;","path":"services.list.1.1.header"}}': '' }
while client.data of the same post gives: {"0":{"value":"alega","path":"services.list.1.0.header"},"1":{"value":"agafonov  ","path":"services.list.1.1.header"}}
which is ok for the parser.

@tshemsedinov
Copy link
Member

This example works well:
Client side example:

$(document).on('click', '#menuPostJSON', function() {
    var parameterName = 'paramaterValue';
    panelCenter.empty().html('<div class="progress"></div>');
    $.post(
        '/examples/simple/jsonPost.json',
        { parameterName: parameterName },
        function(res) {
            panelCenter.html('<pre>'+JSON.stringify(res, null, 2)+'</pre>');
        }
    );
});

Server side handler:

module.exports = function(client, callback) {
    application.requestCounter = application.requestCounter || 0;
    console.dir(client.fields);
    callback({
        status: 1,
        parameterValue: client.fields.parameterName,
        valueLength:    client.fields.parameterName.length,
        requestCounter: application.requestCounter++
    });
}

Server console output:

{ parameterName: 'paramaterValue' }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant