I am trying to send ajax request. following is the code
var parameters = '?dbSid='+dbSid+ '&dbPort='+dbPort+ '&dbIpAddress='+dbIpAddress+ '&dbUserName='+dbUserName+ '&dbPassword='+dbPassword;
new Ajax.Request('../pages/invoke-oracletestAgentCred.jsp'+parameters, {onSuccess:successFunction , onFailure:errorFunction });
If I send dbPassword
as abcd then it works fine.
But when i send dbPassword
as #abc it fails and sets the dbPassword
to blank.
Please help to solve the issue.
Thanks, Anjali
The # character has special meaning in URLs (it indicates the start of the document fragment).
Make sure you encode your URL components (with encodeURIComponent
).
Have you tried using encodeUriComponent?
var parameters = '?dbSid='+encodeUriComponent(dbSid)+ '&dbPort='+encodeURIComponent(dbPort)+ '&dbIpAddress='+encodeURIComponent(dbIpAddress)+ '&dbUserName='+encodeURIComponent(dbUserName)+ '&dbPassword='+encodeURIComponent(dbPassword);
new Ajax.Request('../pages/invoke-oracletestAgentCred.jsp'+parameters, {onSuccess:successFunction , onFailure:errorFunction });
The reason a # breaks your url is that a # is used to go to a anchor in a page. That's why a browser will cut off any url at an #.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.