title: Pass Javascript $_GET variables to CodeIgniter Model via AJAX
body: <p>Good Morning, Im using the Google Maps V3 to implement a project.</p>
  
  <p>In my view, an infowindow opens that the user input data. I want to save that data to my database.</p>
  
  <p>My addMarker model function should grab the entered data and save it to my database.
  Currently, the infoWindow opens and I can enter information. But that data isn't sent to the 
  addMarker function in my model.</p>
  
  <pre><code>function saveData() {
  
  
        var name = escape(document.getElementById("name").value);
        var item = escape(document.getElementById("item").value);
        var type = document.getElementById("weapon").value;
        //var latlng = marker.getPosition();
       var url= "http://localhost:8888/index.php/site_model/addMarker?name="+ name
      +"&amp;item="+item+"&amp;weapon="+weapon;
  
   downloadUrl(url, function(data, responseCode) {
          if (responseCode == 200 &amp;&amp; data.responseText &lt;= 1) {
            infowindow.close();
            document.getElementById("message").innerHTML = "Location added.";
          }
  
  else
      {alert('NOT done');
      alert('TEST');
      }
        });
  
  function downloadUrl(url, callback) {
        var request = window.ActiveXObject ?
            new ActiveXObject('Microsoft.XMLHTTP') :
            new XMLHttpRequest;
  
        request.onreadystatechange = function() {
          if (request.readyState == 4) {
            request.onreadystatechange = doNothing;
            callback(request.responseText, request.status);
          }
        };
  
        request.open('GET', url, true);
        request.send(null);
      }
  
      function doNothing() {}
  </code></pre>
  
  <p>addMarker Model function in Site_model</p>
  
  <pre><code>function addMarker()
      {
          $data = array(
              'name' =&gt;$this-&gt;input-&gt;post('name'),
              'item' =&gt;$this-&gt;input-&gt;post('item'),
              'lat' =&gt;$this-&gt;input-&gt;post('lat'),
              'lng' =&gt;$this-&gt;input-&gt;post('lng'),
              'weapon' =&gt;$this-&gt;input-&gt;post('weapon'),
              'injured' =&gt;$this-&gt;input-&gt;post('injured')
          );
  
          $insert = $this-&gt;db-&gt;insert('data', $data);
          return $insert;
      }
  </code></pre>