Link to home
Start Free TrialLog in
Avatar of altariamx2003
altariamx2003Flag for Mexico

asked on

how to avoid redundand ajax calls

Hi guys

Im working in a new project where i push a button where using this ajax code:
	function loadData(del_name)
	  $("#cont_part1").html(''); 
	  $.ajax
      ({type: "POST", url: "olga-json.php", data: { rID:'<?php echo $_SESSION['MM_rID']; ?>', estado: del_name, fluido:document.getElementById("fluido").value, temp_min:document.getElementById("temp_min").value, temp_max:document.getElementById("temp_max").value, temp_num:document.getElementById("temp_num").value, pres_min:document.getElementById("pres_min").value, pres_max:document.getElementById("pres_max").value, pres_num:document.getElementById("pres_num").value },
        success: function(msg)
	    {
	       $(document).ajaxComplete
		   (
	          function(event, request, settings)
		      {  $("#cont_part").html(msg);  $("#cont_part1").html(''); losresultados = ""; });
		   }   
	    });
    }

Open in new window


I produce this html links
 
    <a href="javascript:void(0);" class="latemp">10</a>
   <a href="javascript:void(0);" class="latemp">18</a>

Open in new window


and when I do a click under any of that links I use this following code to perform actions for the page:
    $(".latemp").on("click", function(e)
	//$(".latemp").click(function(e)	
	//$( document ).on( 'click', '.latemp', function(e)
	{

});

Open in new window



When I do click on any of the dynamic links for the first time evryting works great, but no matter what i try when i do click for second time the page calll 2 times the following ajax code:
	  $.ajax
        (
		  {
			type: "POST", url: "propnoexiste-json.php", 
		    data: { rID:'<?php echo $_SESSION['MM_rID']; ?>', fluido:temp2[1], temp:eltexto, pres_min:document.getElementById("pres_min").value, pres_max:document.getElementById("pres_max").value, pres_num:document.getElementById("pres_num").value },
            success: function(msg)
	        {
	           $(document).ajaxComplete
		       (
	             function(event, request, settings)
		         { 
			       var elmsg = msg.split("SEPARA");
			          if(losresultados != "")
			       { losresultados = losresultados+"SEPARAR"+'temp'+eltexto+"|"+elmsg[1]; }
				   else
				   { losresultados = 'temp'+eltexto+"|"+elmsg[1]; }	
			       $("#cont_part1").html(elmsg[0]);  
		         }
		    );
	        }                 
		  } 
        );

what I missing?? what im doing wrong???

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of altariamx2003

ASKER

it works bro, but now

$("#cont_part1").html(elmsg[0]);  

Open in new window


do not show any content
That's a separate issue.
Check your console (F12) to see what is being returned from the server.

Show us what that data looks like raw - the more info you give us the easier it will be to assist you.
works now bro

thx a lot for help
You are most welcome.