title: CasperJS click event having AJAX call
body: <p>I am trying to fetch data from a site by simulating events using CasperJS with phantomJS 1.7.0.</p>
  
  <p>I am able to simulate normal click events and select events. But my code fails in following scenario:</p>
  
  <p>When I click on button / anchor etc on remote page, the click on remote page  initiates an AJAX call / JS call(depending on how that page is implemented by programmer.). </p>
  
  <p>In case of JS call, my code works and I get changed data. But for clicks where is AJAX call is initiated, I do not get updated data.</p>
  
  <p>For debugging, I tried to get the page source of the element container(before and after), but I see no change in code. </p>
  
  <p>I tried to set wait time from 10 sec to 1 ms range, but that to does not reflect any changes in behavior. </p>
  
  <p>Below is my piece of code for clicking. I am using an array of CSS Paths, which represents which element(s) to click.</p>
  
  <pre><code>/*Click on array of clickable elements using CSS Paths.*/
  fn_click = function(){
  casper.each(G_TAGS,function(casper, cssPath, count1) 
                      {
                              casper.then ( function() {
                              casper.click(cssPath);
  
                              this.echo('DEBUG AFTER CLICKING -START HTML ');
                              //this.echo(this.getHTML("CONTAINER WHERE DETAILS CHANGE"));
                              this.echo('DEBUG AFTER CLICKING -START HTML');
                              casper.wait(5000, function() 
                                                      {   
  
                                                          casper.then(fn_getData);
                                                      } 
                                      );
                              });     
                      });
  };
  </code></pre>
  
  <p>UPDATE:</p>
  
  <p>I tried to use remote-debug option from phantomJS, to debug above script. 
  It is not working. I am on windows. I will try to run remote debugging on Ubuntu as well. </p>
  
  <p>Please help me. I would appreciate any help on this. </p>
  
  <p>UPDATE:</p>
  
  <p>Please have a look at following code as a sample. </p>
  
  <pre><code>https://gist.github.com/4441570
  </code></pre>
  
  <p>Content before click and after click are same. </p>
  
  <p>I am clicking on sorting options provided under tag (votes / activity etc.). </p>