How to pass arguments to jQuery function?

How to pass arguments to jQuery function?

Hello!
 
I have a page that display all the projects created by customer. These projects have phases. The user/customer clicks on the project and a div slides down to show all the phases related to that project. I used javascript & AJAX to achieve this functionality. The AJAX function was taking "projectID" to get phases for that project. That's why, clicking on each project gives different phases. Now I want to achieve same functionality by using jQuery. I wrote the following code:
 
  1. function displayphases (projectid) {
  2. jQuery().ready (function (){
        jQuery("#image2" + projectid).click (function (){
         jQuery("#phases" + projectid).load ('phases.php?projectid=' + projectid);
         jQuery("#phases" + projectid).slideToggle ("slow");
        });
               });




  3. }
The problem with this code is that ".slideToggle" function of jQuery is not working correctly. It does toggle the div (named: #phases + projectid) but on each click the toggle effect is multiplied by 2. For example, on first click the div will slide down, on second click the div will slide up & again slide down, on 3rd click the div will slide up then slide down & then again slide up.
 
I have managed to find out the bug. It is caused by 'onclick="displayphases (projectid);".' If I remove this from
 
  1. <img src="" id="image2<?php echo ($projectid); ?>" onclick="displayphases(<?php echo ($projectid); ?>);" />
then ".slideToggle" functionality of jQuery works fine. But if I am going to remove it from there then how am I going to pass "projectID" to AJAX???
 
Please, help me! I am really in trouble.