Ajax call in package is not working

Permalink
Hello everybody!
I'm trying to do an ajax call. But the result is, that the class I've defined is not found. The full call was not successfull.
This is based on the tutorial you will find athttp://c5hub.com/learning/ajax-57-style/...
I've changed it to work from a package
It should be included in a single page.

My structure:
packages/nak_newsletter/ajax/ajax.php
namespace Concrete\Package\NakNewsletter\Ajax;
class Ajax extends Controller {
    public function processForm() {
        $animal = Request::getInstance()->get('favorite');
        $th = Core::make('helper/text');
        $animal = $th->sanitize($animal);
        echo 'You told us your favorite animal is a "' . $animal . 
             '", so we updated this page with that information using AJAX. Boom!'; 
    }     
}


view.php
<?php
defined('C5_EXECUTE') or die('Access Denied.');
$form = Loader::helper('form');
$opts = array('dog' => 'Dog', 'cat' => 'Cat');
echo $form->label('animal', 'Which animal is best?');
echo $form->select('animal', $opts, 'dog');
?><div id="ajax-content">Return</div>
<script type="text/javascript">
    $(document).ready(function () {
        $('#animal').on('change', function (e) {
            alert("Aua");
            var animal = $(this).val();
            alert ("Animal ist: " + animal);
            $.ajax({
                url: "<?php echo URL::to('nak_newsletter/process_form'); ?>/" + escape(animal),


packages/nak_newsletter/controller.php
namespace Concrete\Package\NakNewsletter;
use Package;
use Database;
use BlockType;
use Concrete\Core\Backup\ContentImporter;
use AssetList;
use Asset;
use Route;
defined('C5_EXECUTE') or die('Access Denied.');
class Controller extends Package {
    protected $pkgHandle = 'nak_newsletter';
    protected $appVersionRequired = '5.7.1';
    protected $pkgVersion = '0.0.2';
...
 public function on_start() {


The return message is: "\Concrete\\Package\\NakNewsletter\\Ajax\\Ajax\" does not exist."

Can anybody help me?

Thanks!
Chris

 
BHWW replied on at Permalink Reply
BHWW
I know it was a long time ago, but I have the same issue, do you remember if you solved this?

Thanks in advance!