AJAX file uploads in Rails using attachment_fu and responds_to_parent 1
2014-03-10 20:49
537 查看
转自:https://github.com/markcatley/responds_to_parent
说明:rails中模拟ajax方式上传文件
插件下载地址:ruby script/plugin install http://responds-to-parent.googlecode.com/svn/trunk/
Adds responds_to_parent to your controller to respond to the parentdocument of your page. Make Ajaxy file uploads by posting the form to ahidden iframe, and respond with RJS to the parent window.
说明:rails中模拟ajax方式上传文件
插件下载地址:ruby script/plugin install http://responds-to-parent.googlecode.com/svn/trunk/
Adds responds_to_parent to your controller to respond to the parentdocument of your page. Make Ajaxy file uploads by posting the form to ahidden iframe, and respond with RJS to the parent window.
Example
Controller:
class Test < ActionController::Base def main end def form_action # Do stuff with params[:uploaded_file] responds_to_parent do render :update do |page| page << "alert($('stuff').innerHTML)" end end end end
main.rhtml:
<html> <body> <div id="stuff">Here is some stuff</div> <form target="frame" action="form_action"> <input type="file" name="uploaded_file"/> <input type="submit"/> </form> <iframe id='frame' name="frame"></iframe> </body> </html>
相关文章推荐
- AJAX file uploads in Rails using attachment_fu and responds_to_parent
- AJAX file uploads in Rails using attachment_fu and responds_to_parent2
- Uploading File using Ajax and receiving binary data in Asp.net (C#)[转]
- using iscroll.js and iscroll jquery plugin in android webview to scroll div and ajax load data.
- Send and Receive JSON objects to Web Service Methods using jQuery AJAX in ASP.Net
- BI Java 补丁错误处理 :Cannot login to the SAP J2EE Engine using user and password as provided in the Filesystem Secure Store. Enter va
- Using MERGE in SQL Server to insert, update and delete at the same time
- How to Include ASM File and to Highlight Display in Source Insight
- Count Arguments to a DOS Batch File without Using Your Fingers and Toes
- A Guide To using IMU (Accelerometer and Gyroscope Devices) in Embedded Applications.
- How to upload a file via a HTTP multipart request in Java without using any external libraries
- I learned several ASP.NET's AJAX ability today! It is so interesting and so easy to use AJAX in ASP.NET.
- Using ZipLib to create a Zip File in C#
- Creating Vista Gadgets: Using HTML, CSS and JavaScript with Examples in RSS, Ajax, ActiveX (COM) and
- Using SOM to get a feature in a file
- 【MySQL笔记】解除输入的安全模式,Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column To disable safe mode, toggle the option in Preferences -> SQL Queries and reconnect.
- Applications using Launch Screen Files and targetting iOS 7.1 and earlier need to also include a Launch Image in an Asset Catalog.
- Using CURL to download a remote file from a valid URL in c++
- Robbie's Notes on File System Security in Linux (and comparison to Windows NT)
- Android: How to download the latest zip Android Source Code easily and using it in Intellij