How can I iterate through my entries?
The way you want to achieve this won't work. Twig is just a render engine for php so you can't execute it during your runtime. You could load all entries during the page load and create a twig filter to json_decode them in order to gain access with javascript or you can do something really really nasty like 

{% set allEntries = craft.entries.section('comics').order('id asc') %}
&lt;script&gt;
    var entries = [];
    {% for entry in allEntries %}
        entries.push({
            title: "{{ entry.title }}",
            body: "{{ entry.body }}",
            url: "{{ entry.getUrl() }}"
            // ..... 
        });
    {% endfor %}
&lt;/script&gt;


To get an array of objects in javascript. But I would not suggest this. The clean way would be to create an ajax request and fetch the entry with php

Have a look at this to learn how to create an ajax request to a controller. You would have to change your controller to:

public function actionSearchEntry()
{
    $id = craft()-&gt;request-&gt;getParam('id');
    $element = craft()-&gt;elements-&gt;getElementById($id);

    $criteria = craft()-&gt;elements-&gt;getCriteria(ElementType::Entry);
    $criteria-&gt;section = "comics";
    $criteria-&gt;orderBy = "id asc";
    if(!$nextElement = $element-&gt;getNext($criteria)){
        $this-&gt;returnJson([
            'success'   =&gt; false
        ]);
    }

    $this-&gt;returnJson([
        'element'      =&gt; [
            'title' =&gt; $nextElement-&gt;title,
            'body'  =&gt; $nextElement-&gt;body,
            // ....
            'id'    =&gt; $nextElement-&gt;id
        ],
        'success'   =&gt; true
    ]);
}


In your javascript you'll create an ajax request and change the values to the one you received if it was successful (if not there will be probably no other entries.