js callback function
<p>How can I callback to a function in an object?</p>

<pre><code>json_post('get_tracks', 'json.request.php?get=tracks', 'genreId='+id+'&amp;perPage=70&amp;page=1', 'rtn_tracks');
</code></pre>

<p>Instead of making a callback to rtn_tracks() I want to do it to this.rtn()</p>

<p>How can I define this in the callback string?</p>

<p>Here is the code:</p>

<pre><code>function stream_tracks(){
 this.get = function(id){
  json_post('get_tracks', 'json.request.php?get=tracks', 'genreId='+id+'&amp;perPage=70&amp;page=1', 'rtn_tracks');
 };

 this.rtn = function(json_obj){
  this.cnstr(json_obj);
 };

 this.cnstr = function(json_obj){
  alert('test');
 };
}
Stream_tracks = new stream_tracks();

var XMLHTTP = {};
function json_post(request_uid, uri, get_str, callback_function, callback_var){
 request_uid += Math.floor(Math.random()*999999).toString();

 if(window.XMLHttpRequest){
  XMLHTTP[request_uid] = new XMLHttpRequest();
 }
 else if(window.ActiveXObject){
  XMLHTTP[request_uid] = new ActiveXObject('Microsoft.XMLHTTP');
 }

 XMLHTTP[request_uid].open('POST', uri, true);
 XMLHTTP[request_uid].setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
 XMLHTTP[request_uid].onreadystatechange = function(){
  if(XMLHTTP[request_uid].readyState == 4){
   if(callback_function){
    eval(callback_function+'('+XMLHTTP[request_uid].responseText+(callback_var ? ', callback_var':'')+')');
   }
  }
 }
 XMLHTTP[request_uid].send(get_str);
}
</code></pre>
