cant access the response from an ajax request outside that function
===

I am  trying to create a recursive function which has ajax request in it. I am trying to access an array which is processed in side the ajax request , from outside recursive function, bt it returns the initial value.

My code looks like 

    
      function retreiveData(testArgument)
			{
			$.ajax({
			url:"testManipulate.php",
			type: 'POST',
			data: 'dataString',
			datatype: 'json',
			data: {field : queryData, start : testArgument},
			success:function(jsonQuery)
			{
			
			$.ajax({
				url: base_uri + path,
				type:'POST',
                		data : jsonQuery,
				success : function(terms){
				var responseJson=JSON.parse(terms); // response JSON generated on download button click
				for ( var g = 0; g < responseJson.hits.hits.length; g++) {
				test[g] = (_generate_list(c, _field_select)); //function
				if(test[g].length!==0){ //Leaving out blank entries
				newTest[k]=test[g].join("; ") + "\n"; //separating each individual values with semi colon
			        k++;
			}
			}
			if(testArgument < (4-1)*10)
		        {
		               retreiveData(testArgument+10);
		        }
				i++
				}
			});
		};
		retreiveData(0);
		alert(newTest.length);


alerting newTest.length will only alert 0, it wont give the final value, ie the array length. What could be wrong?