Reputation: 135
I'm trying to implement an ajax request using jQuery in the Zend Framework. I created a controller with a test action as represented on the code below:
class CompareController extends Zend_Controller_Action {
public function init() {
/* Initialize action controller here */
}
public function indexAction() {
}
public function testAction() {
}
}
My ajax request using jQuery looks like this:
$.ajax({
type: "POST",
url:"<?php echo $this->url(array('controller' => 'compare', 'action' => 'test')); ?>",
data: dataString,
success: function(msg) {
}
How should I declare the url to execute the test action from the zend controller upon receipt of the request?
Any help will be greatly appreciated!
Upvotes: 1
Views: 2076
Reputation: 4382
You can also use baseUrl() function like :
$.ajax({
type: "POST",
url:"<?php echo $this->baseUrl(); ?>/compare/test",
data: dataString,
success: function(msg) {
}
});
Upvotes: 3