Capturing Form Data and submitting to an Ajax call

Capturing Form Data and submitting to an Ajax call

I am just getting started here and have this working fine for me.  It retrieves 4 items from a flicker feed.  (Look familiar?)

  1. <!DOCTYPE = html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <title>My Test Page</title>
  6. <script type = "text/javascript" src = "jquery.js"></script> 
  7.  <div id=rating></div>
  8. </head>

  9. <body>
  10. <h1>Flicker feed</h1>
  11. <div id="images"></div>
  12. <script>
  13. // Start after document has loaded)
  14. $(function(){
  15.     RunAjax()
  16. });

  17. // This is what you run
  18. function RunAjax() 
  19. {
  20.    var tag = "cat"
  21.     $.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?tags="+ tag + "&tagmode=any&format=json&jsoncallback=?",
  22.     function(data)
  23.     {$.each(data.items, function(i,item)
  24.   {$("<img/>").attr("src", item.media.m).appendTo("#images");
  25.   if ( i == 3 ) return false;
  26.   });
  27.   });
  28.         };
  29. </script>
  30. </body>
  31. </html>
What I would like to do is to have my variable, "tag" be the result of a form submission on the page.
My form can be as simple as the following:
  1. <form id="flickerform">
  2. <fieldset>
  3. <legend>Flicker Search Feed</legend>
  4. <label>Parameter:</label>
  5. <input type="text" id="tags" name="tags" />
  6. <button type="submit">Search</button>
  7. </fieldset>
  8. </form>

So when one clicks on the Submit button, I want it to take take the value of my tags form field and pass it to my RunAjax function and return the data corresponding to that tag value.
I am not clear on how to make that request within the form action and method.  Any help would be greatly appreciated.