如何将动态生成的元素保存到数据库? [英] How do you save a dynamically generated element to your database?

查看:106
本文介绍了如何将动态生成的元素保存到数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设您使用Embedly API并在application.js文件中进行调用:

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);
});

现在你有了 oembed 在回调函数中调用例如 ombed.thumbnail_url 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.

jQuery代码看起来像这样:

Would the jQuery code look something like this:

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


推荐答案

看起来你只需要张贴标题thumbnail_url使用AJAX返回到您的应用程序 - http://en.wikipedia.org/wiki/Ajax_(programming) )。

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).

jQuery ajax api非常简单 - http://api.jquery.com/jQuery.ajax/

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

这篇关于如何将动态生成的元素保存到数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆