Tuesday, 20 August 2013

AJAX Autosave and Rails API callback

AJAX Autosave and Rails API callback

So assume that I have a Rails app in which users can write their own blog
posts of sorts. I'd like the user to be able to open a new page for
creating blog posts, and have the blog post automatically be created
through a AJAX call on keyup. However, once the post is created I'd like
every keyup after that to automatically update the post that was
originally created.
I know how to perform the AJAX call on keyup, and I know how to perform an
AJAX call every so often after a keyup, but I don't know how to get the
unique ID of the post back so each save after the first is an update to
the original post.
This is a typical Rails app with publicly accessible API routes, I just
need to be given the created posts ID on a successful AJAX PUT request.
Advice? This seems like it should be relatively simple.

No comments:

Post a Comment