-1

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

3

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
Sign up to request clarification or add additional context in comments.

1 Comment

i used this but happening other error: "Invalid web service call, missing value for parameter: 'sUserName'."

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.