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
Ajax Post Url
Moderator: General Moderators
Re: Ajax Post Url
Just make sure it's within a quoted string.
Re: Ajax Post Url
I believe there is a function similar to url_encode in javascript you can use.
-
mickeyunderscore
- Forum Contributor
- Posts: 129
- Joined: Sat Jan 31, 2009 9:00 am
- Location: UK
Re: Ajax Post Url
escape()astions wrote:I believe there is a function similar to url_encode in javascript you can use.
Re: Ajax Post Url
Is escape() the best function to use?
-
mickeyunderscore
- Forum Contributor
- Posts: 129
- Joined: Sat Jan 31, 2009 9:00 am
- Location: UK
Re: Ajax Post Url
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
http://www.w3schools.com/jsref/jsref_escape.asp