Cannot retrieve value on client side
The problem here appears to be the location in which you are calling drupal_add_js(). The way Drupal works with form submissions, is that after processing is complete, it does a redirect to the page again. This way when you click back (or forward) in the browser, you don't get the message asking you if you want to post the data again. You are adding your JS in a processing function, which happens before the redirect, so it is getting lost after the redirect.

You'll need to find a different location to put your call to drupal_add_js(), that comes after the redirect. It should go in the same place where you are loading your script in the first place.