Hi, > Once the AJAX reply comes back that the data was updated, I want to > destroy the form. But it won't let me. I guess for a similar reason to > my explanation above - the button started the call, and it is in the > response code that I wish to destroy it, so it technically hasn't > finished yet.
No, that actually won't give you any trouble. No reason you can't remove the form from the response handler of an Ajax request initiated by an event handler on the form or one of its elements. "...wont' let [you]" *HOW*? Specifics count for a lot, as does (again) a _small_ self-contained test page. The links you've put up are not to small self-contained stuff, but to largish stuff most people aren't going to bother to read through. Burn it down to the pure product, a few lines of code that do the thing (or don't do the thing), and you'll almost certainly figure it out -- and if not, again, you'll have something nice and small to post to ask for help with. -- T.J. Crowder Independent Software Consultant tj / crowder software / com www.crowdersoftware.com On Dec 6, 5:57 pm, evilC <[email protected]> wrote: > Thanks TJ, I tried to make a self-contained version, so I ripped out > prototype and did the same thing with object literals, and I still had > issues, so clearly it wasnt prototype. > In the end I figured out that the button which fired off the AJAX > request (ie the "Submit" button) was inside a form (I did not want it > to actually do an HTTP POST submission of the form, just call JS code) > and I had not disabled the form with onsubmit='return false', so when > I clicked submit, it was submitting the form, thus destroying the > button that made the AJAX call before the reply came back. > > I had noticed that putting an alert or delay into the script caused it > to work and was tearing my hair out - obviously the delay stopped the > button being destroyed long enough for the AJAX request to come back. > > Oh the joys of Asynchronous web coding. > > I now have a slightly different problem, with the same button... > > Once the AJAX reply comes back that the data was updated, I want to > destroy the form. But it won't let me. I guess for a similar reason to > my explanation above - the button started the call, and it is in the > response code that I wish to destroy it, so it technically hasn't > finished yet. I hope that all makes sense. If not, I will try and rig > some self contained code using the system you linked - I guess for the > ajax request I could just get it to grab a css file or something off > the server? -- You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" 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/prototype-scriptaculous?hl=en.
