0

This is my try and this is executed by onclick event !

var post_array = {
    data_post: postData
}; //Array 
$.ajax({
    url: "location/add-names",
    type: "POST",
    data: post_array,
    success: function (data, textStatus, jqXHR) {
        //data - response from server
    },
    error: function (jqXHR, textStatus, errorThrown) {

    }
});

And the PHP code:

<?php

class LocationController extends \Lunchbox\Controller
{
    public function indexAction()
    {
     ...................
    }
    public function addNamesAction(){
        echo 1;
    }
}

Route :

 $location = new Zend_Controller_Router_Route('locatie/:locationUrl/:day', 
            array('module'     => 'default', 'controller' => 'location', 'day' => Cronos::getCurrentDayName()),
            array('day' => Cronos::$weekDayRegex)
        );
        $router->addRoute('location', $location);

I want to display "1" after the ajax event. But the firebug show me this error: "404 Not Found". I'm a newbie in zend so please give me a reasonable answer. Thx :D

now the debug.log shows me this :

2014-04-14T09:57:09+03:00 CRIT (2): ----------------
2014-04-14T09:57:09+03:00 CRIT (2): URL: /location/add-names
2014-04-14T09:57:09+03:00 CRIT (2): script 'location/add-names.phtml' not found in path (/home/lunchbox/public_html/application/views/scripts/)
#0 /opt/ZendFramework-1.12.3/library/Zend/View/Abstract.php(884): Zend_View_Abstract->_script('location/add-na...')
#1 /opt/ZendFramework-1.12.3/library/Zend/Controller/Action/Helper/ViewRenderer.php(900): Zend_View_Abstract->render('location/add-na...')
#2 /opt/ZendFramework-1.12.3/library/Zend/Controller/Action/Helper/ViewRenderer.php(921): Zend_Controller_Action_Helper_ViewRenderer->renderScript('location/add-na...', NULL)
#3 /opt/ZendFramework-1.12.3/library/Zend/Controller/Action/Helper/ViewRenderer.php(960): Zend_Controller_Action_Helper_ViewRenderer->render()
#4 /opt/ZendFramework-1.12.3/library/Zend/Controller/Action/HelperBroker.php(277): Zend_Controller_Action_Helper_ViewRenderer->postDispatch()
#5 /opt/ZendFramework-1.12.3/library/Zend/Controller/Action.php(527): Zend_Controller_Action_HelperBroker->notifyPostDispatch()
#6 /opt/ZendFramework-1.12.3/library/Zend/Controller/Dispatcher/Standard.php(308): Zend_Controller_Action->dispatch('addNamesAction')
#7 /opt/ZendFramework-1.12.3/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#8 /opt/ZendFramework-1.12.3/library/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch()
#9 /opt/ZendFramework-1.12.3/library/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#10 /home/lunchbox/public_html/index.php(31): Zend_Application->run()
#11 {main}

cand someone help me with this ?

3
  • Have you added this route to your module.config.php? Or are you using other restrictions like an ACL? Commented Apr 11, 2014 at 11:29
  • please check my post again Commented Apr 11, 2014 at 11:30
  • try giving only addNames in the url of ajax if not working take a look at this : stackoverflow.com/questions/8485726/… Commented Apr 11, 2014 at 11:32

1 Answer 1

0

Couple things I can see here.

  1. The route you have shown is for '/locatie/:locationUrl/:day' however the route you need is for '/location/add-names
  2. in the ajax - the camel case that you use would indicate a url of add-names . the uppercase letter splits the url with a -

Hope that helps

Sign up to request clarification or add additional context in comments.

1 Comment

thx man , but now im not getting the 404 error, im getting this: "500 Internal Server Error", any ideea or tips , why ? thx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.