简体   繁体   中英

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. I included a javascript file in a custom module and followed the procedure explained below. 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(
    {
         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

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

But while makinf call , it is giving me an error like this -

   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

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). 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 . This is not an error, but you will get along with the framework much easier if you follow the existing naming conventions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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