I have a function
function getCalendarData(){
   ob_start();
   echo "<script type='text/javascript' src='http://splocal/courses/calendar.js'></script>";
   $calendarAry = ob_get_contents();
   print_r($calendarAry);
   return $calendarAry;
 }
here i am trying to assign the return value of js call to a variable . but its not working.
what is the correct way of doing it?
calender.js file 
    function returnCalenderArray(data){
        console.log(data);
        document.write(data);
        return data;
    }
    $.ajax({
         type: "GET",
         url: "http://localhost:8080/privateTraining/getTrainingsJson",
         data: { ListID: '1'},
         dataType: "jsonp",
         success: function(data) {
         alert('Hi'+data);
         returnCalenderArray(data);
      }
});  
 
     
    