title: jQuery custom template not working properly
body: <p>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:</p>
  
  <blockquote>
    <p>Uncaught SyntaxError: Unexpected end of input</p>
  </blockquote>
  
  <p>How would I go about doing this? The code I have written so far is shown below:</p>
  
  <pre><code>$("#projects").click(function () {
      jQuery.ajax({
          type: "POST",
          dataType: "JSON",
          url: "&lt;?=base_url()?&gt;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();
                      });
                  });
              }
          }
      });
  });
  </code></pre>
  
  <p>Here is my Php:</p>
  
  <pre><code>function projectsSlider() {
      $query  = $this-&gt;db-&gt;query("SELECT * FROM projects ORDER BY idprojects DESC");
      foreach ($query-&gt;result() as $row) {
          $projectId = $row-&gt;projectId;
          $projectName = $row-&gt;projectName;
          $startDate = $row-&gt;startDate;
          $finishedDate = $row-&gt;finishedDate;
          $createdFor = $row-&gt;createdFor;
          $contributors = $row-&gt;contributors;
          $projectDesc = $row-&gt;projectDesc;
      }
      $query1 = $this-&gt;db-&gt;query("SELECT * FROM screenshots s WHERE s.projectId = '{$projectId}' ORDER BY s.idscreenshot DESC");
      foreach ($query1-&gt;result() as $row2) {
          $screenshotURI = $row2-&gt;screenshotURI;
          $websiteURL = $row-&gt;websiteURL;
      }
      echo json_encode(array('returned' =&gt; true,
          'projectId' =&gt; $projectId,
          'projectName' =&gt; $projectName,
          'startDate' =&gt; $startDate,
          'finishedDate' =&gt; $finishedDate,
          'projectDesc' =&gt; $projectDesc,
          'createdFor' =&gt; $createdFor,
          'contributors' =&gt; $contributors,
          'screenshotURI' =&gt; $screenshotURI,
          'websiteURL' =&gt; $websiteURL));
  }
  }
  </code></pre>
  
  <p>Any ideas as to why this is happening?</p>