-1

Have a example object:

data = {
    var1: 'val 1',
    var2: 'val 2'
}

Hot to transform to application/x-www-form-urlencoded content?, with jquery transform only from form objects but not from javascript objects.

The expect: var1=val+1&var2=val+2

0

1 Answer 1

0

You can do something like this to iterate over the object:

Object.keys(data).map(x=>x+'='+data[x]).join('&').replace(/ /g,'+')

Result:

var1=val+1&var2=val+2

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.