1) Make sure you're running the latest version (1.6)
2) I'm not sure how well IE handles selectors on uninserted
elements
so it would be safer to append it to the document first.
$(document.body).insert(new Element('div', {id:
'_proxy'}).hide());
3) Ajax.Updater is more appropriate when updating elements
via ajax
new Ajax.Updater('_proxy', url, {
method: 'get',
onComplete: function() {
$('content-title').update($('_proxy').down('#title').innerHT
ML);
$('content-text').update($('_proxy').down('#content').innerH
TML);
}
})
4) It would be more convenient if your server could return
JSON
instead of an html {"title": "foo",
"content": "bar"}. The above
snippet would only take few lines:
new Ajax.Request(url, {
method: 'get',
onSuccess: function(resp) {
var data = resp.responseJSON;
$('content-title').update(data.title);
$('content-text').update(data.content)
}
})
Best,
kangax
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-spinoffs-unsubscribe googlegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=
en
-~----------~----~----~----~------~----~------~--~---
|