I'm not getting concatenate the variables to make an acceptable result for json, can someone give me an idea of the correct form of concatenation?
I'm doing this:
date: '{"sUserName": "' + nomeUser'","' + + '" sPassword ":"' + password +'"}',
and the result is as follows:
{"sUserName": "a", "" sPassword ":" a "}
Programmer Bruce
67.3k7 gold badges101 silver badges97 bronze badges
1 Answer 1
Replace:
'{"sUserName": "' + nomeUser'","' + + '" sPassword ":"' + password +'"}'
with
'{"sUserName": "' + nomeUser + '","' + 'sPassword":"' + password +'"}'
You have an extra '+' and an extra ". And here's a simple way to avoid this in the future:
var obj = {}; obj.sPassword = 'test'; obj.sUserName = 'p'; JSON.stringify(obj)
answered Jul 5, 2011 at 0:47
Joe
82.9k18 gold badges130 silver badges147 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
Fernando Braçaroto
i used this but happening other error: "Invalid web service call, missing value for parameter: 'sUserName'."
lang-js