简体   繁体   English

ActiveCollab-如何在页面加载时从自定义模块进行Ajax调用

[英]ActiveCollab - How to make an ajax call from a custom module on page load

I'm trying to initiate an ajax call on project brief page by adding a javascript file.I need to display some extra information along with existing project brief information. 我试图通过添加一个javascript文件在项目简介页面上发起ajax调用。我需要显示一些额外的信息以及现有的项目简介信息。 I included a javascript file in a custom module and followed the procedure explained below. 我在自定义模块中包含了一个javascript文件,并按照以下说明的步骤进行操作。 Can you correct me If I'm missing anything here. 如果我在这里遗漏任何东西,您能纠正我吗?

I used $.ajax({}) to call the ajax request and my code is like this 我使用$ .ajax({})来调用ajax请求,我的代码是这样的

    $.ajax(
    {
         type: "post",
         url: "index.php?path_info=projectfieldsextra",
         'data' : { 'client_value' : 178}, 
         success: function(el)
         {
               alert(el);
               return false;
            //$("#project").html(el);
           }
    });

In controller I created a function get_project_information() and in module definition class I created a route like this 在控制器中,我创建了一个函数get_project_information(),在模块定义类中,我创建了这样的路由

     Router::map('projectfieldsextra', 'projectfieldsextra', array('controller' => 'project_fields', 'action' => 'get_project_information'));

But while makinf call , it is giving me an error like this - 但是在makinf通话时,它给了我这样的错误-

   Call to a member function isInlineCall() on a non-object in /opt/lampp/htdocs/activecollab/activecollab/4.0.13/angie/frameworks/environment/controllers/FwApplicationController.class.php on line 211

Could anyone help me out in this ? 有人可以帮我吗?

Thanks in advance Jayesh 在此先感谢Jayesh

My best guess is that your custom controller ( ProjectFieldsController ) is not properly set up (it is not properly accepting construction parameters and transferring them to the parent class). 我最好的猜测是您的自定义控制器( ProjectFieldsController )的设置不正确(它没有正确接受构造参数并将其传递给父类)。 If you are overriding controller's constructor, you should do it like this: 如果要覆盖控制器的构造函数,则应这样进行:

/**
 * Controller constructor
 *
 * @param Request $parent
 * @param mixed $context
 */
function __construct($parent, $context = null) {
  parent::__construct($parent, $context);

  // Your code
}

Note that there are other problems with your code, but they are not part of the question, so I will mention them just briefly: 请注意,您的代码还有其他问题,但它们不是问题的一部分,因此我将简要介绍一下它们:

  1. Don't hack the system module. 不要破解系统模块。 That's a recipe for upgrade problems. 那是解决升级问题的秘诀。 Write your own module that hooks into the system via supported events instead. 编写您自己的模块,该模块通过支持的事件挂接到系统中。
  2. System convention is to use underscore notation for various system names, including route names. 系统约定是对各种系统名称(包括路由名称)使用下划线符号。 show_project_info is much more readable than showprojectinfo . show_project_infoshowprojectinfo更具可读性。 This is not an error, but you will get along with the framework much easier if you follow the existing naming conventions. 这不是错误,但是如果遵循现有的命名约定,您将更容易与框架相处。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM