Added header('Access-Control-Allow-Origin: *'); to api.php