title: Pass several variable to a function Jquery
body: <p>Noob question incoming: Im using the jquery function loadNewPicture() to load picture (obviously) and the function progress() to see the achievement in percent of the upload.</p>
  <p>Everything is working fine.</p>
  <p>My question concerns only the variables that I can pass to the function &quot;progress().&quot; This function is a template that I took somewhere. It passes fine the variable &quot;e&quot; without specifiying it when using it by default:</p>
  <p><strong>myXhr.upload.addEventListener('progress', progress, false);</strong></p>
  <p>But I dont know how to pass more variables.
  I would like to pass the variable &quot;category&quot; so I was expecting something like this:</p>
  <p><strong>myXhr.upload.addEventListener('progress', progress(e, category), false);</strong></p>
  <p>But it does not work.
  Any idea?</p>
  <pre><code>function loadNewPicture(category, idT)
                      //id pour l'element que l'on va cacher
                      //vari pour les variables a seter du style ?prout=&quot;xxx&quot;
                      {
                               
                          var form_data = new FormData();     
                          var ins = document.getElementById(idT).files.length;
                          for (var x = 0; x &lt; ins; x++) 
                          {
                              form_data.append(&quot;file[]&quot;, document.getElementById(idT).files[x]);
                          }
                          
                          //form_data est une liste. Je rajoute un element a cette liste afin de l'envoyer dans le POST
                          form_data.append('category', category); 
                          
                          $.ajax(
                          {
                              url: 'ajax/saveNewPicture.php', // point to server-side PHP script 
                              dataType: 'text',   // what to expect back from the PHP script, if anything
                              cache: false,
                              contentType: false,
                              processData: false,
                              data: form_data,                                             
                              type: 'post',
                              xhr: function() 
                              //### CA VA PERMETTRE DE SAVOIR LE POURCETAGE DE UPLOAD DES PHOTOS
                              {
                                  var myXhr = $.ajaxSettings.xhr();
                                  if(myXhr.upload)
                                  {
                                      //console.log(&quot;CA UPLOAD&quot;);
                                      myXhr.upload.addEventListener('progress', progress, false);
                                  }
                                  return myXhr;
                              },
                              success: function(php_script_response)
                              {
                                  $(&quot;#presultat&quot; + category).html(php_script_response);
                              },
                              error: function (php_script_response) 
                              {
                                  $(&quot;#presultat&quot; + category).html(php_script_response);
                              }
                          });
                      }
                      
                      function progress(e, category)
                      //### CETTE FONCTION SERT A AFFICHER LEVOLUTION DE LUPLOAD DES PHOTOS SUR LE SERVEUR.
                      {
                          if(e.lengthComputable)
                          {
                              var max = e.total;
                              var current = e.loaded;
  
                              var Percentage = (current * 100)/max;
                              $(&quot;#presultatDownloadprm&quot;).html(&quot;UPLOAD : &quot; + Percentage);
  
                              if(Percentage &gt;= 100)
                              {   
                                  $(&quot;#presultatDownloadprm&quot;).html(&quot;UPLOAD REUSSI.&quot;);
                              }
                          }   
                      }
  </code></pre>