Page 1 of 1

Ajax Post Url

Posted: Wed Feb 04, 2009 6:37 pm
by kerepuki
Hey guys,

I have a problem where i want to send the current page url to a php function using ajax however everytime there is a & or ? the php script reads this as another parameter and doesnt receive the correct value. For example: 'http://www.google.com.au/search?hl=en&q ... arch&meta='. From this url I can only get 'http://www.google.com.au/search' and everything else is ignored.

How can I send the url intact ignoring all ? and & or any other character I choose?

Thanks

Re: Ajax Post Url

Posted: Wed Feb 04, 2009 9:04 pm
by califdon
Just make sure it's within a quoted string.

Re: Ajax Post Url

Posted: Wed Feb 04, 2009 9:27 pm
by Benjamin
I believe there is a function similar to url_encode in javascript you can use.

Re: Ajax Post Url

Posted: Thu Feb 05, 2009 3:49 am
by mickeyunderscore
astions wrote:I believe there is a function similar to url_encode in javascript you can use.
escape()

Re: Ajax Post Url

Posted: Thu Feb 05, 2009 3:44 pm
by kerepuki
Is escape() the best function to use?

Re: Ajax Post Url

Posted: Thu Feb 05, 2009 3:47 pm
by mickeyunderscore
As far as I know, escape() is the only client-side option for URL-encoding a string. There is some information on it here:

http://www.w3schools.com/jsref/jsref_escape.asp