Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: jQuery
I am using this code to append div when i click or submit the button
<script type="text/javascript">
    $(document).ready(function() {
        var divProcessing = '<div><img src="/Images/processing.gif" alt="Processing.."/></div>';
        $(".btnProcessing").click(function() {
            $(this).hide().after().parent().append(divProcessing);
        });
 
    });
        
</script>
 
But some times when i click the submit button multiple divs(it displays multiple images) are added...
 
Pls tell why its append multiple divs..
 
any one say how to solve this problem............
 

 
And then i remove the div tag
<script type="text/javascript">
    $(document).ready(function() {
        var divProcessing = '<img src="/Images/processing.gif" alt="Processing.."/>';
        $(".btnProcessing").click(function() {
        $(this).hide().after().parent().append(divProcessing);
        });
 
        var prm = Sys.WebForms.PageRequestManager.getInstance();
        prm.add_endRequest(function() {
            $('.btnProcessing').click(function() {
            $(this).hide().after().parent().append(divProcessing);
            });
        });
    });
        
</script>
 
But now i have same issue but the image is added multiple times but horizontally..
 
If i am using div the image is added multiple time vertically..
 
why its occur...
Posted 26-Sep-12 20:16pm
Edited 28-Sep-12 1:56am
v5
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

<script type="text/javascript">
    $(document).ready(function() {
        var divProcessing = '<div><img src="/Images/processing.gif" alt="Processing.."/></div>';
        $(".btnProcessing").click(function() {
                document.getElementById("div").appendChild(divProcessing);
        });
     });
 
</script>
  Permalink  
Comments
saravana__ at 27-Sep-12 5:01am
   
I think append() and appendChild() both are same difference is in java script we use appenChild() and jquery we use append()...... Tell me there is any difference between these two things..
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Try this..
 
<script type="text/javascript">
    $(document).ready(function() {
        var divProcessing = '<div><img src="/Images/processing.gif" alt="Processing.."/></div>';
        $(".btnProcessing").click(function() {
            $(this).hide().after().parent().html(divProcessing);
        });
 
    });
 
</script>
  Permalink  
Comments
saravana__ at 27-Sep-12 4:43am
   
Tell me why that issue occurs
saravana__ at 27-Sep-12 4:45am
   
Its not working for me now also the above code add multiple divs
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

working example:
 
http://jsfiddle.net/PSHWZ/12/[^]
 
bye
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
saravana__ at 27-Sep-12 5:08am
   
The above code is not working for me.. Why the processing image is displayed multiple times...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Shai Vashdi 540
1 Tadit Dash 305
2 Sergey Alexandrovich Kryukov 250
3 Peter Leow 190
4 OriginalGriff 148
0 Sergey Alexandrovich Kryukov 9,395
1 OriginalGriff 5,473
2 Peter Leow 4,150
3 Maciej Los 3,540
4 Abhinav S 3,333


Advertise | Privacy | Mobile
Web03 | 2.8.140415.2 | Last Updated 28 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid