...

View Full Version : return innerHTML oncomplete



Idfk
08-26-2011, 04:28 PM
How can i return this innerHTML on complete?


deleteUser: function( id ) {

elm = $( 'user_' + id );

Effect.Pulsate( elm, {duration: 1, pulses: 2} );
Effect.Fade( elm, {delay: 1, duration: 0.5} );

new Ajax.Request( 'ajax', {

method: 'post',
parameters: {mode: 'deleteUser', id: id},
onComplete: function( transport ) {
innerHTML = "<div class=\"good\"></div>";
}

} );

}
the fade works but i want to return the div to say deleted successfuly.

desiter
08-26-2011, 06:39 PM
You can't just use innerHTML alone because it is always a property of some DOM element. It means in JavaScript you have to always use someElement.innerHTML = "some new content";.

To summarize you your code should look something like:

deleteUser: function( id ) {

elm = $( 'user_' + id );

Effect.Pulsate( elm, {duration: 1, pulses: 2} );
Effect.Fade( elm, {delay: 1, duration: 0.5} );

var confirmBox = $('confim-box');
new Ajax.Request( 'ajax', {

method: 'post',
parameters: {mode: 'deleteUser', id: id},
onComplete: function( transport ) {
confirmBox.innerHTML = "<div class=\"good\"></div>";
}

} );

}

Additionally you need to create a DIV element to hold the confirm message. Place it at top of the table with user list for example.

Here is the additional HTML I'm talking about - you need to add it to you page source.

<div id="confim-box"></div>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum