I am trying to urlencode this string before I submit.
JavaScript
x
2
1
queryString = 'eventName=' + evt.fields["eventName"] + '&' + 'eventDescription=' + evt.fields["eventDescription"];
2
Advertisement
Answer
You need to pass your parameters into urlencode()
as either a mapping (dict), or a sequence of 2-tuples, like:
JavaScript
1
5
1
>>> import urllib
2
>>> f = { 'eventName' : 'myEvent', 'eventDescription' : 'cool event'}
3
>>> urllib.urlencode(f)
4
'eventName=myEvent&eventDescription=cool+event'
5
Python 3 or above
JavaScript
1
3
1
>>> urllib.parse.urlencode(f)
2
eventName=myEvent&eventDescription=cool+event
3
Note that this does not do url encoding in the commonly used sense (look at the output). For that use urllib.parse.quote_plus
.