user3664644 February 2016

javascript windows.location string picking

I have this URL:

http://localhost/estamo/asset.php?aname=VklQIFBsYXph&di=Ng==

And I will need get that using Javascript

var locat = window.location.href;     
$.get("enviaramigo.php?email="+$("#email").val()+"&url="+locat, function(html) {

But, when I use the locat var, I will get this incomplete URL:

http://localhost/estamo/asset.php?aname=VklQIFBsYXph

How to I get the complete URL?

Thanks

Answers


jcubic February 2016

You need to encode the url using encodeURIComponent

var locat = window.location.href;     
$.get("enviaramigo.php?email="+$("#email").val()+"&url="+encodeURIComponent(locat), function(html) {

or base64

$.get("enviaramigo.php?email="+$("#email").val()+"&url="+btoa(locat), function(html) {

and you will need to decode on the sever.

Post Status

Asked in February 2016
Viewed 3,300 times
Voted 8
Answered 1 times

Search




Leave an answer