title: $.ajax() call not working as I would like it to
body: <p>So I make this ajax call:</p>
  
  <pre><code>$.ajax({
     type: "POST",
     url: "/videos",
     data: { title: oembed.title }
  });
  </code></pre>
  
  <p>inside this function call to the Embedly API:</p>
  
  <pre><code>$('a.oembed').embedly({maxWidth:300,'method':'replace'}).bind('embedly-oembed', function(e, oembed){ 
  });
  </code></pre>
  
  <p>Now there's two things wrong with the way this $.ajax() call is working. First, it's being calling every time I load the <code>index</code> view, which makes sense because that's where I'm pointing the url. However, I want it to be called just once when the video is created, and I don't know how to point it to just the <code>create</code> method.</p>
  
  <p>Second, the ajax call is just adding an empty row to the database, and the title, which is generated dynamically by the embedly API and stored in the <code>oembed</code> hash (the selector finds the video link in my view and turns it into an embedded video, as well as stores all of the video's attributes in <code>oembed</code>), is not being inserted into my database. I'm trying to store this dynamically generated title into my database.</p>
  
  <p>How do I accomplish both of these goals?</p>
  
  <p>UPDATE: If you're curious and want to see this in action, fork the code here: <a href="https://github.com/meltzerj/Dreamstill" rel="nofollow">https://github.com/meltzerj/Dreamstill</a></p>
  
  <p>UPDATE 2: Here's what the console says. Note that one is for <code>create</code> and the other is for <code>show</code>:</p>
  
  <p>Started POST "/videos" for 127.0.0.1 at Wed Mar 16 03:03:12 -0700 2011
    Processing by VideosController#create as 
    Parameters: {"title"=>"Exclusive: Charlie Sheen Says He's 'Not Bipolar but 'Bi-Winning' (02.28.11)"}
    AREL (0.4ms)  INSERT INTO "videos" ("description", "thumbnail_url", "released", "video_url", "user_id", "title", "embed_code", "created_at", "updated_at") VALUES (NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2011-03-16 10:03:12.277518', '2011-03-16 10:03:12.277518')
  Redirected to <a href="http://localhost:3000/videos/413" rel="nofollow">http://localhost:3000/videos/413</a>
  Completed 302 Found in 17ms</p>
  
  <p>Started GET "/videos/396" for 127.0.0.1 at Wed Mar 16 03:03:03 -0700 2011
    Processing by VideosController#show as 
    Parameters: {"id"=>"396"}
    Video Load (0.2ms)  SELECT "videos".* FROM "videos" WHERE "videos"."id" = 396 LIMIT 1
  Rendered videos/_show_video.html.erb (6.4ms)
  Rendered videos/show.html.erb within layouts/application (9.8ms)
  Completed 200 OK in 33ms (Views: 24.5ms | ActiveRecord: 0.2ms)</p>