我正在尝试在 Zend 框架中使用 jQuery 实现 ajax 请求。我创建了一个带有测试操作的 Controller ,如下面的代码所示:
class CompareController extends Zend_Controller_Action {
public function init() {
/* Initialize action controller here */
}
public function indexAction() {
}
public function testAction() {
}
}
我使用 jQuery 的 ajax 请求如下所示:
$.ajax({
type: "POST",
url:"<?php echo $this->url(array('controller' => 'compare', 'action' => 'test')); ?>",
data: dataString,
success: function(msg) {
}
收到请求后,我应该如何声明从 zend Controller 执行测试操作的 url?
任何帮助将不胜感激!
最佳答案
您还可以使用 baseUrl() 函数,例如:
$.ajax({
type: "POST",
url:"<?php echo $this->baseUrl(); ?>/compare/test",
data: dataString,
success: function(msg) {
}
});
关于zend-framework - 如何在 jQuery ajax 请求中声明 url 以从 zend Controller 执行操作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9555124/