title: Favorites star switching in Javascript
body: <p>A good example is the SO star on the left hand side of this post.</p>
  
  <p>You can click on it to add this message in your favorite and click again to remove this flag.</p>
  
  <p>I already create a page /favorites/add/{post_id}/ but how to handle that in Ajax ?</p>
  
  <p>Many things to do :</p>
  
  <ul>
  <li>Be sure that it worked when you click</li>
  <li>Change the image</li>
  <li>Change the link if it is to add or remove the flag.</li>
  </ul>
  
  <p>I am sure such a thing already exists, but I couldn't find it.</p>
  
  <p>Any idea ?</p>