Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
61
rated 0 times [  62] [ 1]  / answers: 1 / hits: 21667  / 12 Years ago, mon, november 5, 2012, 12:00:00

I am hitting a struts action using AJAX, everything is fine but there is problem with Firefox , when i am passing the parameter in URL as a request parameter and if that parameter, contains hash(#) symbol in the end, then firefox strips everything after that symbol and send that parameter to action without it.



For example, if im passing test123#abcd in Firefox, then i am getting only test123 in action class as opposed to test123#abcd which is undesirable for my requirement.For IE it is working perfectly.Is there any way by which i can extract the full parameter including the # symbol in Firefox.



please let me know if i need to post the java action code also,thanks.



JS snippet



var valuePassword=test123#abcd;

var url = /test/ChangePwdAjax.do?newPass=+valuePassword;
var xmlHTTP = getXMLHTTPRequest();

More From » ajax

 Answers
30

Use



var url = /test/ChangePwdAjax.do?newPass=+ encodeURIComponent(valuePassword);


This will encode your valuePassword to a valid URL component which can be passed as a query string in URLs



And on the other side you should use decodeURIComponent to get the value from encoded string



var value = decodeURIComponent(valuePasswordPassed);


To know more about this Go here


[#82196] Friday, November 2, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
maya

Total Points: 418
Total Questions: 116
Total Answers: 112

Location: Mauritania
Member since Sun, Oct 17, 2021
3 Years ago
maya questions
Sun, Jul 4, 21, 00:00, 3 Years ago
Tue, Dec 22, 20, 00:00, 4 Years ago
Fri, Nov 6, 20, 00:00, 4 Years ago
Wed, Jul 29, 20, 00:00, 4 Years ago
Tue, Apr 21, 20, 00:00, 4 Years ago
;