How to add a javascript function after uploading file I make a form using FAPI, and this form contains a file managed field. I want to show an alert after uploading the file ("uploaded successfully"), and a confirmation ("Are you sure you want to delete file") when deleting the file. 

This my code.

$form['my_file_fid'] = array(
  '#type' =&gt; 'managed_file',
  '#title' =&gt; t('Files'),
  '#default_value' =&gt; variable_get('my_file_fid', ''),
  '#upload_location' =&gt; 'public://',
); 


I tried to add #file_value_callbacks, but I don't know how to use it.

I tried to make a javascript just to alert when I click upload,remove button but it doen not work I tried to make it general to all input to check that js is correct now all inputs are clickable but upload and remove button not

jQuery(document).ready(function() {
         jQuery('input').bind('click',function() { alert("hi") });
 });  


I make this js to check jquery ajaxSuccess function
You could just bind something to the jQuery ajax success event on the page where your form is displayed.

You can bind ajaxSuccess to any jQuery object, try something like this if you're experimenting:

&lt;script&gt;
  (function ($) {
    $(function () {
      jQueryObject = $({});
      jQueryObject.ajaxSuccess(function(event, XMLHttpRequest, ajaxOptions) {
        /* do something whenever an ajax call is successful */
      });
    });
  })(jQuery);
&lt;/script&gt;