Retrieving next_post_link() and previous_post_link() in functions.php

<?php
function get_all_images($post_id=0, $size="poster", $attributes="") {
    global $post;
    setup_postdata($post);
    $post_id = $_POST['post_id'];
    if ($post_id<1) $postid = get_the_ID();
    $post = get_post($post_id);
    $get_content = $post -> post_content;
    $content = apply_filters('the_content', $get_content);
    $content = str_replace(']]>', ']]&gt;', $content);
    $title = get_the_title($post);
    $previous_post = get_previous_post();
    $next_post = get_next_post();
    $previous_link_url = get_permalink(get_previous_post(false,'',true));
    $next_link_url = get_permalink(get_next_post(false,'',false));
    if (!empty( $previous_post )) $previous_link = '<div class="post-control right"><a href="'.$previous_link_url.'" rel="prev">&rsaquo;</a></div>';
    if (!empty( $next_post )) $next_link = '<div class="post-control left"><a href="'.$next_link_url.'" rel="next">&lsaquo;</a></div>';
    if ($images = get_children(array(
        'post_parent' => $post_id,
        'post_type' => 'attachment',
        'numberposts' => -1,
        'orderby' => 'menu_order',
        'post_mime_type' => 'image',))) 
        $response = $previous_link.$next_link.'<div class="post-titles titles">'.$title.'<span class="ajust-icon pull-right"><a href="https://wordpress.stackexchange.com/blog" class="backtoblog"><i class="icon-remove icon-white"></i></a></span></div>';
        foreach($images as $image) {
            $attachment=wp_get_attachment_image_src($image->ID, $size);
            $tranparent=get_template_directory_uri();
            $response .= '<img src="'.$tranparent.'/images/transparent.gif" data-original="'.$attachment[0].'" alt="" class="imarge" />';
        }
    die(json_encode($response.$content));
}?>