URL parameter being trimmed after white space
URL parameter being trimmed after white space
Hi,
I'm struggling with an odd problem that I can't get my head around.
I have a column with a URL that then adds a URL as a parameter e.g.
http://urlDisp.aspx?Location=http://test/test doc 1.pdf
Below is my code to render this:
{ "data": "URL",
"render": function (data, type, row, meta) {
return '<a href=urlDisp.aspx?Location='+ data +'>'+data+'</a>';
}
},
The problem I can't get around is that if there is a space in the url that is used the parameter is trimmed after the first space, so the above example would look like:
http://urlDisp.aspx?Location=http://test/test
I know its probably something simple, but I'm completely stumped! Any help would be appreciated!
Steve
Answers
I meant to say, the visible URL text looks fine - the file address is displayed correctly, but the URL parameter is truncated.
If I understand it correctly, you want to put a white space inside a link? Like
http://urlDisp.aspx?Location=http://test/test doc 1.pdf
, right?You can't use spaces in URLs, but you need to escape it. This URL must be render using
+
or%20
characters.Try to use the encodeURI() to generate the link. On server, most languages automatically decode spaces as
+
for you, like PHP $_GET, or have builtin functions, like urldecode.