Web Analytics Made Easy -
StatCounter return innerHTML oncomplete - CodingForum

Announcement

Collapse
No announcement yet.

return innerHTML oncomplete

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • return innerHTML oncomplete

    How can i return this innerHTML on complete?

    Code:
    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.

  • #2
    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:
    Code:
    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.
    Code:
    <div id="confim-box"></div>
    Descript.org - lightweight JavaScript foundation framework

    Comment

    Working...
    X