Part of the EllisLab Network
   
 
pass data through loc.href
Posted: 16 May 2008 03:11 AM   [ Ignore ]  
Summer Student
Avatar
Total Posts:  22
Joined  05-08-2008

i want a js value to be passed to another function

var placevalue='Ponsonby, Auckland, New Zealand';

when i use

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?

Profile
 
 
Posted: 16 May 2008 03:26 AM   [ Ignore ]   [ # 1 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1250
Joined  01-07-2008

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:

$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 .

 Signature 

Blog | Twitter | Coffee

Profile
 
 
Posted: 16 May 2008 04:32 AM   [ Ignore ]   [ # 2 ]  
Summer Student
Avatar
Total Posts:  22
Joined  05-08-2008

this is the eg url
http://localhost/wee/index.php/place/address_result/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.

Profile
 
 
Posted: 16 May 2008 04:42 AM   [ Ignore ]   [ # 3 ]  
Summer Student
Avatar
Total Posts:  22
Joined  05-08-2008

this is the example url i m posting again

http://localhost/wego/index.php/place/address_result/Ponsonby, Auckland, New Zealand/-36.852356 174.738688

Profile
 
 
Posted: 16 May 2008 06:40 AM   [ Ignore ]   [ # 4 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1250
Joined  01-07-2008

Oh, duh - no commas.  What you’re looking for is encodeURIComponent .

 Signature 

Blog | Twitter | Coffee

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 719, on June 06, 2008 10:16 AM
Total Registered Members: 62661 Total Logged-in Users: 40
Total Topics: 77197 Total Anonymous Users: 0
Total Replies: 416734 Total Guests: 238
Total Posts: 493931    
Members ( View Memberlist )