title: Cakephp how to make ajax request with jsHelper
body: <p>I want to rewrite this jQuery Ajax Request which is not working well with cakePHP with a code block in my cakePHP view using JsHelper. 
  So far, I've setup everything( included the helper in my controller, written the buffer in my Layout, included my library(jQuery) ), but I dont know how to rewrite this:</p>
  
  <pre><code>         $.ajax
              ({
                  url: 'clients/loadJsonMarkers',
                  accepts: 'json',
                  type: 'POST',
                  data: postData,
                  dataType: 'json',
                  error: function(xhr,status,err){
                      alert("DEBUG: status"+status+" \nError:"+err);
                  },  
                  success: function(transport)
                  {   
  
                      var markers = new Array();
  
                      for(var i in transport.clients)
                      {
                          var latlng = transport.clients[i].Client.geoloc.replace("(", "");
                          latlng = latlng.replace(")", "");
                          latlng = latlng.split(',');
  
                          //console.debug(latlng);
                          markers.push(new google.maps.LatLng(parseFloat(latlng[0]),parseFloat(latlng[1])));
                      }
  
                      loadMap(markers);
  
                  }
              });
  </code></pre>
  
  <p>What I've achieved to write so far was this:</p>
  
  <pre><code>    $this-&gt;Js-&gt;get('document');
      $this-&gt;Js-&gt;event('load',
              $this-&gt;Js-&gt;request(
                  array('action' =&gt; 'loadJsonMarkers'),
                  array('assync'=&gt;TRUE, 'type'=&gt;'json', 'method'=&gt;'POST', 'data'=&gt;$_POST)
                  ),
              array('success'=&gt;$this-&gt;Html-&gt;scriptBlock("
                      function(transport)
                      {   
                          var markers = new Array();
  
                          for(var i in transport.clients)
                          {
                              var latlng = transport.clients[i].Client.geoloc.replace('(', '');
                              latlng = latlng.replace('(', '');
                              latlng = latlng.split(',');
  
                              //console.debug(latlng);
                              markers.push(new google.maps.LatLng(parseFloat(latlng[0]),parseFloat(latlng[1])));
                          }
  
                          loadMap(markers);
  
                      }"
              ))
      );
  </code></pre>
  
  <p>But I feel like something is missing and I don't know if I should use this selector(document). </p>