1
var jspcall = "commonchart?userRole=" + btoa(userRole) + "&temName=" +btoa("TempOne");
     window.location.href = jspcall;

I want to pass userRole data and temName data using url. Therefor I create above java script code. But when I getting data I cannot get true userRole data. How can I filter return value in userRole data. temName data is ok.

var userRole = location.search.split('userRole=')[1];
    //var userrole = atob(userRole);
    alert(userRole);
    var temName = location.search.split('temName=')[1];
    var temname = atob(temName);
    alert(temname);

userRole return value like that YnVmZmVyLXN0b2Nr&temName=VGVtcE9uZQ== How can I split correct data for finding userRole data.

  • It looks like you need a function that will allow you to get querystring parameters from the URL. See the following StackOverflow answer for a function that will do that: http://stackoverflow.com/a/901144/579148 – jwatts1980 Apr 24 '16 at 22:04
  • Is this data encoded by any chance? See functions like encodeURI(), decodeURI(), encodeURIComponent(), etc. – user6245342 Apr 24 '16 at 22:04
  • The functions atob is for base64 decoding and btoa is for base64 encoding. You need to first get the query string, split it by '&' and then find first string after '=' then do a atob. – randominstanceOfLivingThing Apr 25 '16 at 00:59

0 Answers0