I've started with the samples included with prototype.js which has the
following code in the fillin example (a portion of which I want to
isolate into its own function).
The original code looks like this ([COLOR="red"]red[/COLOR] is what I
want to isolate):[CODE]
function dofill( ) {
new Ajax.Updater( 'result', 'getdata.php', { method: 'post',
parameters: $('myform').serialize(),
onSuccess: [COLOR="Red"]function( transport ) {
$('elFirst').value =
transport.responseXML.getElementsByTagName('first')
[0].firstChild.nodeValue;
$('elLast').value =
transport.responseXML.getElementsByTagName('last')
[0].firstChild.nodeValue;
$('elEmail').value =
transport.responseXML.getElementsByTagName('email')
[0].firstChild.nodeValue;
}[/COLOR] } );
}
[/CODE]
What I created was this:[CODE]
function fill_in(transport) {
$('elFirst').value =
transport.responseXML.getElementsByTagName('first')
[0].firstChild.nodeValue;
$('elLast').value =
transport.responseXML.getElementsByTagName('last')
[0].firstChild.nodeValue;
$('elEmail').value =
transport.responseXML.getElementsByTagName('email')
[0].firstChild.nodeValue;
}
function dofill() {
new Ajax.Updater( 'result', 'getdata.php', { method: 'post',
parameters: $('myform').serialize(),
onSuccess: function ( transport ){
fill_in(transport);
} } );
}
[/CODE]
I cant seem to get this to work... but I'm not getting any errors
either. The idea is to make the fill_in() independent so that it can
be easily changed and updated and this allows the dofill() to be stuck
in a .js file.
I dont understand why transport wont just pass as a variable. How do
I do this?
Thanks,
Pete
--
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.