Welcome Guest, Not a member yet? Register   Sign In
pass data through loc.href
#1

[eluser]PHPraja[/eluser]
i want a js value to be passed to another function
Code:
var placevalue='Ponsonby, Auckland, New Zealand';

when i use
Code:
location.href="<?php echo site_url(); ?>/place/address_result/"+placevalue+"/"+latlongvalue;
it throws this error.
The URI you submitted has disallowed characters.

i also tried with escape(), urlencode(),base64_encode().
it again throws urlencode is not defined in js error console.

Any how i want the value with ','(comma) to be sent to a function. Can any one guide me?
#2

[eluser]Pascal Kriete[/eluser]
Can you give us an example URI?

In your application/config/config.php file there is a variable that defines what characters are allowed. It should read something like this:
Code:
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';

Urlencode is a php function, the javascript equivalent is encodeURI( ) . Try using that and it should work Smile .
#3

[eluser]PHPraja[/eluser]
this is the eg url
http://localhost/wee/index.php/place/add...t/Ponsonby, Auckland, New Zealand/-36.852356 174.738688

as there are commas its not allowing,
though i use encodeURI i got the same error. Any other solution.
#4

[eluser]PHPraja[/eluser]
this is the example url i m posting again
Code:
http://localhost/wego/index.php/place/address_result/Ponsonby, Auckland, New Zealand/-36.852356 174.738688
#5

[eluser]Pascal Kriete[/eluser]
Oh, duh - no commas. What you're looking for is encodeURIComponent .




Theme © iAndrew 2016 - Forum software by © MyBB