drupal_add_js and drupal_flush_all_caches I was trying to call drupal_add_js in the callback of a button. It seems, even with after_build, that this can be done successfully only you are working without cached data. 

So, before i start the page, i run drupal_flush_all_caches, and the javascript is successfully added to the page.

The problem is I want to get some user input data from a form, pass to the javascript and exibit the result. The way i'm trying to do, it is getting a string that contains the processed values and concatenating with another string that contains the other part of the javascript (probably this is not a good practice), and calling this string with drupal_add_js. But, when if i call drupal_flush_all_caches, the form will be reset and i will not be able to get the data.

So, my questions are: How can i pass values from a form to a javascript? 

Do i need to flush all caches every time to use drupal_add_js?

Is there different solutions to deal with this during development and production?



Thanks for the help guys. I found some answers:   How can i pass values from a form to a javascript? I had to name my variable as Drupal.settings.myModule.myVar in the javascript code. This way i can pass variables from php code to javascript. If you want to modify the javascript code you really need to flush caches. Until now, i have not found nothing about differences between production and development best pratices.
Is there any problem with writing a menu callback that does this, and processing in PHP?

If you must use JavaScript for the processing, why not intercept the user's value in JavaScript and never "really" submit the form?