title: XMLHttpRequest response from php function containing no data
body: <p>I am using a codeigniter application that dynamically generates some html elements based on a database query returned from a function in my model.</p>
  
  <p>In one of my views I use XMLHttpRequest to call a php function in one of my controllers which in turn gets data from my model in the form of a string and echos it for the responseText.  My javascript code looks like this:</p>
  
  <pre><code>var xmlHttp = new XMLHttpRequest();
  xmlHttp.open("POST", "/controller/my_function", true);
  var postStr = "name="+proposalName+"&amp;data="+data;
  xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
  xmlHttp.send(postStr);
  var response = xmlHttp.responseText;
  </code></pre>
  
  <p>The called function looks like this:</p>
  
  <pre><code>public function my_function(){
  $data['name'] = $this-&gt;input-&gt;post('name');
  $data['data'] = $this-&gt;input-&gt;post('data');
  $string = $this-&gt;my_model-&gt;my_model_function($data);
  echo $string;
  }
  </code></pre>
  
  <p>The model returns the string correctly, and even after just echoing a random number or string in the function it still didn't get anything from the response text.  No matter what i try to echo in the function there doesn't appear to be anything in the response text.  What am i doing wrong here?  How can I get the responseText to grab the correct value from my php function?</p>
  
  <p>Edit: fixed a copying issue with postStr variable</p>