jQuery custom template not working properly
===

I have a custom template setup in Javascript/jQuery and I'm needing to pull data from a CodeIgniter controller and insert the returned JSON into the js/jQuery template. I do believe my logic is correct but for some reason nothing seems to work and I'm getting the following error in the beginning of my script:

> Uncaught SyntaxError: Unexpected end of input

 How would I go about doing this? The code I have written so far is shown below:

    $("#projects").click(function() {
    jQuery.ajax({ type: "POST", dataType: "JSON",
    url: "<?=base_url()?>index.php/home/projectsSlider", data: dataString,
    json: {returned: true}, success: function(data) {
    if(data.returned == true) {
    $("#content").fadeOut(150, function() {
    $(this).replaceWith(projectsSlider(), function() {
    var html = projectsSlider(data.projectId, data.projectName, data.startDate, data.finishedDate, data.createdFor, data.contributors, data.screenshotURI, data.websiteURL);
    jQuery(html).appendTo("#content").fadeIn();
    });
    });
    }
    }
    });
    });


Here is my Php:

    function projectsSlider() {
    $query  = $this->db->query("SELECT * FROM projects ORDER BY idprojects DESC");
    foreach ($query->result() as $row) {
    $projectId = $row->projectId;
    $projectName = $row->projectName;
    $startDate = $row->startDate;
    $finishedDate = $row->finishedDate;
    $createdFor = $row->createdFor;
    $contributors = $row->contributors;
    $projectDesc = $row->projectDesc;
    }
    $query1 = $this->db->query("SELECT * FROM screenshots s WHERE s.projectId = '{$projectId}' ORDER BY s.idscreenshot DESC");
    foreach ($query1->result() as $row2) {
    $screenshotURI = $row2->screenshotURI;
    $websiteURL = $row->websiteURL;
    }
    echo json_encode(array('returned' => true,
    'projectId' => $projectId,
    'projectName' => $projectName,
    'startDate' => $startDate,
    'finishedDate' => $finishedDate,
    'projectDesc' => $projectDesc,
    'createdFor' => $createdFor,
    'contributors' => $contributors,
    'screenshotURI' => $screenshotURI,
    'websiteURL' => $websiteURL));
    }
    }

Any ideas as to why this is happening?