title: how to properly call jquery function from php?
body: <p>UPDATE:</p>
  
  <p>I'm making a like/dislike voting program and it has worked the way I want it in Firefox 3, Chrome, and Safari. However, it doesn't seem to be working in Firefox 4. For example, I've made a form such that after the user clicks the submit button and the data is sent into the SQL table, a jquery animation is supposed to play. This is the full code:</p>
  
  <pre><code>&lt;script type="text/javascript" src="opacity.js"&gt;&lt;/script&gt;
  
  
  
  &lt;link href="voter.css" rel="stylesheet" type="text/css" /&gt;
  
  &lt;?php
  
  
  mysql_connect("","","") or die("Error connecting to db");
  mysql_select_db("") or die("Error connecting to db");
  
  $currAdd2 = $_SERVER["REQUEST_URI"];
  $currAdd2 = substr($currAdd2, 0, -9);
  $currAdd2 = substr($currAdd2, 11);
  
  $numrow1 = mysql_query("SELECT * FROM rate WHERE apt = '$currAdd2' AND likes = 1 ");
  $numlikes = mysql_num_rows($numrow1); 
  
  $numrow2 = mysql_query("SELECT * FROM rate WHERE apt = '$currAdd2' AND likes = 0 ");
  $numdislikes = mysql_num_rows($numrow2);
  
  $numrow3 = mysql_query("SELECT * FROM rate WHERE apt = '$currAdd2'  ");
  $totalvotes = mysql_num_rows($numrow3);
  
  $likewidth = ($numlikes/($totalvotes+1)) * 400;
  $dislikewidth = ($numdislikes/($totalvotes+1)) * 400;
  ?&gt;
  &lt;form action= '&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;'; method='post'&gt;
  &lt;table align='left' width='500px' border='0' cellpadding='0' cellspacing='0'&gt;
  &lt;? echo"      
        &lt;tr&gt;
          &lt;td&gt;
              &lt;div id='blue'&gt;&lt;input type='image' name='blue' id='likebutton' value='blue' src='../zrating/like.png' 
  
              /&gt;&lt;/div&gt;
  
          &lt;/td&gt;
          &lt;td&gt;
          &lt;b&gt;$numlikes Like&lt;/b&gt;
          &lt;div id='like' style='width:$likewidth'&gt;&lt;div id='dis'&gt;&lt;/div&gt;&lt;/div&gt;&lt;br&gt;
          &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td&gt;
              &lt;div id='red'&gt;&lt;input type='image' name='red' id='dislikebutton' value='red' src='../zrating/dislike.png'  
  
              /&gt;&lt;/div&gt;
  
          &lt;/td&gt;
          &lt;td&gt;
              &lt;b&gt;$numdislikes Dislike&lt;/b&gt;
              &lt;div id='dislike' style='width:$dislikewidth'&gt;&lt;div id='dis'&gt;&lt;/div&gt;&lt;/div&gt;&lt;br&gt;
          &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
        &lt;td&gt;
        &lt;/td&gt;
        &lt;td&gt;
        &lt;div id='success'&gt;&lt;br&gt;&lt;br&gt;Thanks for voting!&lt;/div&gt;
        &lt;div id='fail'&gt;&lt;br&gt;&lt;br&gt;You are only allowed 1 vote per apartment.&lt;/div&gt;     
        &lt;/td&gt;
        &lt;/tr&gt;
    &lt;/table&gt;
  &lt;/form&gt;
  ";
  
  
  //check ip address
      if (!empty($_SERVER['HTTP_CLIENT_IP']))   //check ip from share internet
      {
        $ip=$_SERVER['HTTP_CLIENT_IP'];
      }
      elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))   //to check ip is pass from proxy
      {
        $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
      }
      else
      {
        $ip=$_SERVER['REMOTE_ADDR'];
      }
  
  
  
  if ( isset( $_POST['blue'] ) )
  {
  
      $currAdd = $_SERVER["REQUEST_URI"];
      $currAdd = substr($currAdd, 0, -9);
      $currAdd = substr($currAdd, 11);
  
      $ipquery = mysql_query ("SELECT * FROM rate WHERE ip = '$ip' AND apt = '$currAdd' ");
      $ipquery = mysql_fetch_assoc($ipquery);
      $ipquery = $ipquery['ip'];
  
  
      if ($ipquery == $ip)
      {
          echo "&lt;script type='text/javascript' src='jquery.js'&gt;&lt;/script&gt;";
  
  
                  echo "&lt;script type='text/javascript'&gt;
                   $(document).ready(function()
      {
      $('#fail').animate({width:300},1000);
      $('#fail').animate({height:100},1000);
      $('#fail').animate({width:300,height:100},1400);
      $('#fail').fadeOut(5000);
  
      }); &lt;/script&gt;";
  
      }
      else
      {
  
      mysql_query ("INSERT INTO rate VALUES ('','$currAdd', '1', '$ip')");            
  
      $rankqry = mysql_query ("SELECT * FROM rank WHERE apt = '$currAdd' ");
      $rankqry = mysql_fetch_assoc($rankqry);
      $rankqry = $rankqry['rank'];
  
      $rankupdate = $rankqry + 1;
  
          if($rankupdate &lt; 0)
          {
          $rankupdate = 0;
          }
  
      mysql_query ("UPDATE rank SET rank = '$rankupdate' WHERE apt = '$currAdd' ");
      $likesqry = mysql_query ("SELECT * FROM rank WHERE apt = '$currAdd' ");
      $likesqry = mysql_fetch_assoc($likesqry);
      $likesqry = $likesqry['likes'];
  
      $likesupdate = $likesqry +1;
  
      mysql_query ("UPDATE rank SET likes = '$likesupdate' WHERE apt = '$currAdd' ");
  
              echo "&lt;script type='text/javascript' src='jquery.js'&gt;&lt;/script&gt;";
  
  
          echo "&lt;script type='text/javascript'&gt;
                   $(document).ready(function()
      {
      $('#success').animate({width:300},1000);
      $('#success').animate({height:100},1000);
      $('#success').animate({width:300,height:100},1400);
      $('#success').fadeOut(5000);
  
      }); &lt;/script&gt;";
  
  }
  
  }
  
  
  if ( isset( $_POST['red'] ) )
  {
      $currAdd = $_SERVER["REQUEST_URI"];
      $currAdd = substr($currAdd, 0, -9);
      $currAdd = substr($currAdd, 11);
  
      $ipquery = mysql_query ("SELECT * FROM rate WHERE ip = '$ip' AND apt = '$currAdd' ");
      $ipquery = mysql_fetch_assoc($ipquery);
      $ipquery = $ipquery['ip'];
  
      if ($ipquery == $ip)
      {
                  echo "&lt;script type='text/javascript' src='jquery.js'&gt;&lt;/script&gt;";
  
  
                  echo "&lt;script type='text/javascript'&gt;
                   $(document).ready(function()
      {
      $('#fail').animate({width:300},1000);
      $('#fail').animate({height:100},1000);
      $('#fail').animate({width:300,height:100},1400);
      $('#fail').fadeOut(5000);
  
      }); &lt;/script&gt;";
  
  
      }
      else
      {
  
  mysql_query ("INSERT INTO rate VALUES ('','$currAdd', '0', '$ip')");    
  
  $rankqry = mysql_query ("SELECT * FROM rank WHERE apt = '$currAdd' ");
  $rankqry = mysql_fetch_assoc($rankqry);
  $rankqry = $rankqry['rank'];
  
  $rankupdate = $rankqry - 1;
  
  if($rankupdate &lt; 0)
  {
      $rankupdate = 0;
  }
  
  
  mysql_query ("UPDATE rank SET rank = '$rankupdate' WHERE apt = '$currAdd' ");
  
  $dislikesqry = mysql_query ("SELECT * FROM rank WHERE apt = '$currAdd' ");
  $dislikesqry = mysql_fetch_assoc($dislikesqry);
  $dislikesqry = $dislikesqry['dislikes'];
  
  $dislikesupdate = $dislikesqry +1;
  
      mysql_query ("UPDATE rank SET dislikes = '$dislikesupdate' WHERE apt = '$currAdd' ");
  
              echo "&lt;script type='text/javascript' src='jquery.js'&gt;&lt;/script&gt;";
  
  
  
                      echo "&lt;script type='text/javascript'&gt;
                   $(document).ready(function()
      {
      $('#success').animate({width:300},1000);
      $('#success').animate({height:100},1000);
      $('#success').animate({width:300,height:100},1400);
      $('#success').fadeOut(5000);
  
      }); &lt;/script&gt;";
  
  
      }
  }
  ?&gt;
  </code></pre>
  
  <p>I used version 1.4.2 of the jquery library and the latest version but still no luck. Thanks in advance for the help.</p>