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 ?
addNamesin the url of ajax if not working take a look at this : stackoverflow.com/questions/8485726/…