Ok, I read up some more on prototype and I do understand all the ajax concepts etc. My initial problem is that I was attempting to work off of existing code that wasn't written right. So that led me down the wrong path. With the help from you guys I've now finished my project and tested it pretty thoroughly with no bugs. If you couldn't already tell I was trying to replicate flikr by using photonotes.js. Well, I had to heavily modify photonote's to get it working how I wanted it. After a couple days I've now got it working so thanks a million.
On Apr 17, 9:52 am, Ken Snyder <[EMAIL PROTECTED]> wrote: > Ftt wrote: > > Thanks for the tip! I've made the change. I have one last issue that > > maybe someone can help me with. Once I make the ajax.request, the > > request doesn't finish before moving on in my code and returning the > > wrong note.id.... > > It seems like you're not quite understanding the asynchronous concept of > ajax (without it, ajax would be jax). Any "moving on in your code" > needs to be done after onSuccess is called. The "return note.id" at the > end of saveNoteDb is wrong. You'll need to create two functions--see > example below. > > -Ken > > function saveNoteDb(note){ > ... > var ajaxinsert= new Ajax.Request(url, { > method: 'get', > parameters: {...}, > onSuccess: function(transport) { > if (transport.responseText > 0) { > //note saved > note.status = 'saved'; > note.id = 'note' + transport.responseText; > } else { > note.status = 'failed'; > } > showNoteSaveStatus(note); > } > }); > > } > > function showNoteSaveStatus(note) { > $(note) > .addClassName(note.status) > .update(note.status.capitalize()); > > }; > > // i don't know your html structure, but in this example: > // if saved with an id of 100, the note node would now > // have a class of "saved" an innerHTML of "Saved" > // and an id="note100" --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---