javascript - Need to encode/decode a JSON response for passing it to another webpage -


i having website application, need pass 1 json response(in string format) across site. have used hidden type value , passing on submit of link/button triggers page. when checked on waf, throwing cross-site scripting error. since, response contains special characters, suspect root cause of issue. now, want pass json response in encoded format , decode on next webpage. have read many articles , post on this. can suggest best practice implementation on this.

code snippet:

<input type="hidden" name="empstatus" id="empstatus" value=""> //in jsp  $("#empstatus").val(json.stringify(empstatus)); //in js 

you use encodeuricomponent before sending

$("#empstatus").val(encodeuricomponent(json.stringify(empstatus))); //in js

and decodeuricomponent when receiving,

thus protect special enclosing characters "


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -