Question

I'm using jquery accordion to show different sets of information and my accordion looks like this:`

<div id="accordion">
   <h3>Category1</h3>
   <div id="section1">
         < logic to display data for category 1 >
   </div>
   <h3>Category2</h3>
   <div id="section2">
         < logic to display data for category 2 >
   </div>
   <h3>Category3</h3>
   <div id="section3">
        < logic to display data for category 3 >
   </div>
   <h3>Category4</h3>
   <div id="section4">
        < logic to display data for category 4 >
   </div>
   <h3>Category5</h3>
   <div id="section5">
      < logic to display data for category 5 >
   </div>
</div>`

I wanted to know how to track the number of times each header is clicked and i need to send this click count for each header to server side program.Thanks for your help!

Was it helpful?

Solution

I don't know if it's obvious but you can send the information to the server each time the header is clicked :

$('#accordion > h3').click(function(e){
   var header = $(this).html();
   //then send an ajax request to the server
   $.post(yoururl,{category:header});
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top