Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jul 2010
    Location
    Sheffield
    Posts
    827
    Thanks
    93
    Thanked 18 Times in 18 Posts

    AJAX request being sent 15+ times

    This is on a shoutbox, each shout have a delete link where and admin can delete the shout.

    Its a link with onclick =\"deleteShout()\" in it.

    The function is this.

    Code:
    function deleteShout(e){
    			e.preventDefault();
    			var ID2 = $(this).attr("href");
    			$.ajax({
    				type: "POST",
    				url: "_aGadminCp/modules/editShoutbox.php",
    				data: "ID="+ID2,
    				success: function(msg){
    					popUp(msg);
    				}
    			});
    		}
    Is it running multiple times before more than one link has the function on it? If so how could i stop it doing that?

    EDIT: I changed the wrong part of my code, now when i click the link i get e is not defined and the link goes to the number in the href, how can i stop that happening?
    Last edited by tomharto; 10-03-2011 at 12:54 AM.

  • #2
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts
    i think your going to have to show us your html structure, there is nothing tere to indicate a loop of any kind

  • #3
    Regular Coder
    Join Date
    Jul 2010
    Location
    Sheffield
    Posts
    827
    Thanks
    93
    Thanked 18 Times in 18 Posts
    Is this what you mean by html structure?

    This is it uptill the links on the shoutbox.

    Code:
    <body>
    
    <div id="loadHere"></div>
    
    
    	<div id="container">
    
    			<ul id="navigation">
        
    		<center>
            <h1 id="banner"><a href="#">Empire Gammers</a></h1>
    		<!-- sponsors -->
    
    		<div id="sponsors">
    			
    		</div>
            
            
    		<div id="main">
    
    			<!-- 
                <div id="advertisement">
    				Advert
                </div>
                -->
    
    		<div id="content">
    
    			<div class="news">
    
               
    			<!-- Begin ShoutMix - http://www.shoutmix.com -->
    
    	<div class="blockmid" style="width: 647px; height: 488px;">
    		<span class="corners-top"><span></span></span>
    
    			<div style="height: 483px;">
    				<h3 class="block-title"><span style="color: rgb(42, 42, 42);">Shoutbox</span></h3>
                    <div id="shoutDisplay" style="height: 373px; background-color: rgb(57, 57, 57); width: 617px; margin: 0px auto; padding: 5px; overflow-y: auto; overflow-x: hidden;">
                    	<table width="595">
                          <tbody>
                            <tr>
                              <td style="color: rgb(224, 27, 27); padding-bottom: 5px; border-bottom: 1px solid rgb(255, 255, 255); font-size: 1.2em; width: 120px;">SIR SLASH&nbsp;:&nbsp;</td>
                              <td style="padding-bottom: 5px; border-bottom: 1px solid rgb(255, 255, 255); font-size: 1.2em;">Oooo this is looking very sexy haha</td>
                              <td style="padding-bottom: 5px; border-bottom: 1px solid rgb(255, 255, 255); font-size: 0.8em; width: 120px;"><span style="float: right;"> - Sun 11th of Sep at 23:50<br> - <a href="97" class="ban">Ban</a> - <a href="9" class="edit">Edit</a> - <a href="9" onclick="deleteShout()" class="delete">Delete</a>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •