chespinoza
chespinoza

Reputation: 2658

Serialize string to standard URL-encoded notation

I need serialize a string to a standard URL-encoded notation my string has some blank spaces and parentheses:

string = "( 3.141516, 3.1415), 3,1415";

and I need get it at serverside as a only value - var, how can I do that in order to sent it as a query string???

Thanks in advance.

Upvotes: 2

Views: 5365

Answers (1)

Matt Ball
Matt Ball

Reputation: 359876

Without any jQuery at all: encodeURIComponent().

With jQuery, assuming you're using something like $.get():

$.get('http://example.com/', {foo: '( 3.141516, 3.1415), 3,1415'}, callback);

and jQuery will automagically do the URL-encoding for you.

Upvotes: 7

Related Questions