简体   繁体   中英

How do you save a dynamically generated element to your database?

Let's say you use the Embedly API and make the call in your application.js file:

$('a.oembed').embedly({maxWidth:300,'method':'replace'}).bind('embedly-oembed', function(e, oembed){ 
           alert(oembed.title);
});

Now you have the hash oembed and can call, for example, ombed.thumbnail_url or oembed.title in the callback function. I want to know how you would save one of these elements in the call back function to your database.

Would the jQuery code look something like this:

$.ajax({
   type: "POST",
   data: { title: 'oembed.title', thumbnail_url: 'oembed.thumbnail_url'}
});

It looks like you just need to post the title and thumbnail_url back to your application using AJAX - http://en.wikipedia.org/wiki/Ajax_(programming ).

The jQuery ajax api is very straightforward - http://api.jquery.com/jQuery.ajax/ .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM