Thanks for the quick response, Ken! I will try that out and hopefully
I'll be done with my app. You're a life saver.
On Apr 16, 2:23 pm, Ken Snyder <[EMAIL PROTECTED]> wrote:
> Ftt wrote:
> > ...
>
> > var ajaxinsert = new Ajax.Request('insertNote.aspx', {
> > method: 'get',
> > parameters: 'text='+note.text+'&width='+note.rect.width
> > +'&height='+note.rect.height+'&left='+note.rect.left
> > +'&top='+note.rect.top+'&id='+note.id+'&status='+note.status,
> > onSuccess: function(transport) {
> > note.status = 'saved';
> > },
> > onFailure: function(transport) {
> > note.status = 'failed';
> > }
>
> > Basically I'm calling a page "inserNote.aspx" to do my insert into db.
> > This works perfect so far...but I can't find a good way to retreive
> > the PK of the row I just inserted! I've tried using Ajax.Updater but
> > that doesn't seem to be a good method because I don't want to make two
> > ajax calls...I just want to make the one request and retreive the
> > inserted ID...
> > ...
>
> As long as the ajax request is asynchronous, the browser can make the
> request to the server, the server can process the request and insert the
> record then return back the value of the inserted id. Have the aspx
> page echo the id (or 0 on failure) and define your onSuccess function
> along these lines:
>
> onSuccess: function(transport) {
> var id = parseFloat(transport.responseText);
> if (id) {
> note.id = id;
> note.status = 'saved';
> } else {
> note.status = 'failed'
> }
>
> }
>
> The onSuccess should be fired after the aspx page is done processing and
> will receive the output of the aspx page in transport.responseText
>
> - Ken Snyder
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---