Discover how to initiate an ajax request from a tailored module when the page is loaded in ActiveCollab

When trying to initiate an AJAX call on the project brief page by adding a JavaScript file, I encountered some issues. My goal is to display additional information along with the existing project brief. I included a JavaScript file in a custom module and followed the steps outlined below. Can someone please review my approach and let me know if I missed anything?

The code snippet I used for making the AJAX call is as follows:


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

In the controller, I created a function called get_project_information() and in the module definition class, I set up a route like this:


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

However, when making the call, I ran into the following error message:


 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

If anyone could assist me with this issue, that would be greatly appreciated.

Thank you, Jayesh

Answer №1

It appears that the issue may lie in your custom controller (ProjectFieldsController) not being properly configured to accept and transfer construction parameters to the parent class. When overriding a controller's constructor, be sure to follow this format:

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

  // Your code
}

Additionally, there are other issues in your code that should be addressed for better compatibility:

  1. Avoid modifying the system module directly as it can lead to complications during upgrades. It is recommended to write your own module that interacts with the system using supported events.
  2. Follow the system's naming conventions by using underscore notation for system names, such as route names. For example, show_project_info is more readable than showprojectinfo. While not an error, adhering to these conventions will make working with the framework smoother.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Error: Unable to access the 'create' property of an undefined object while utilizing sequelize to register a user and add an entry

Whenever I try to execute this controller, an issue arises indicating a problem with the recognition of the .create method from the model. What is the correct way to import Sequelize in order to utilize it effectively? const db = require("../Models/m_use ...

How can refs be applied effectively in React applications?

I've been thinking about the role of refs in React and how they can address certain challenges for developers. However, I have found that the explanations provided in the React documentation are not very clear, and there seems to be a lack of helpful ...

Can Angular-Material help create a sidenav that toggles on and off?

I am struggling to create a side menu that remains closed by default on all screen sizes and always opens on top of other content. Despite my efforts, it keeps switching at widths over 960px. This is the current code for my menu: <md-sidenav is-locked ...

Incorporate a secondary (auxiliary) class into ReactJS

Looking to create a helper class similar to this: export default class A { constructor() { console.log(1); } test() { console.log(2); } } and utilize it within a component like so: import React, { Component } from "react"; import A from ...

What is the correct way to specify the type in my functional component?

I was trying to define the type in my component in a different way, I know it can be done using classes but is there a way to achieve this with functional components without exporting the interface? Despite my extensive research, I couldn't find any r ...

What is the best way to create an HTML template with a table where the first column is divided into four cells and the second column only has one

Currently, I am working on a template using HTML and CSS. One issue that I am facing involves designing a table template with HTML and CSS. The specific problem occurs in the second row of the table where there are 4 cells in the first column and only one ...

How to retrieve a value from PHP using Ajax?

I am struggling to implement ajax for adding a div to display an error message. Despite my efforts, I keep receiving null as the error message instead of the expected value. The occurrence of null is traced back to <?php echo json_encode($_SESSION[&ap ...

The function addEventListener is not found

When a button is pressed, I want to add a value into a container by adding an event listener. <div className="grid-container"> <div> <button id="redBet" className="redButton" onclick={thi ...

What is the best way to remove extra information from a redirect URL?

Implementing Discord login OAuth2 in JavaScript has been quite a journey. I have managed to redirect to '/auth' upon completion, but the URL for that page comes with additional information like '/auth#token_type=Bearer&access_token=12eka ...

Telegram: verification key mismatch detected

I am currently facing an issue with implementing a Telegram PHP example using JavaScript. The hashes do not match, even after running the example's php code which also resulted in failure with identical hashes. I have tried adjusting my bot settings b ...

PHP is unable to fetch JSON data from an ajax request

My JavaScript code is as follows: var person = []; person[0] = "John"; person[1] = "Doe"; person[2] = 46; var myData = JSON.stringify(person); $.ajax({ type: "POST", url: "test.php", dataType : "text", ...

Why is Django not recognizing my ajax request when using the `is_ajax()` function?

After sending a GET request and processing the data to obtain a redirect link, the function seems to be having trouble entering the is_ajax() block. $(document).on('click', '.top_up_pay', function (e) { var post_data; e.preventDefa ...

Discover the Power of Node.js with the @aws-sdk/client-s3 Package, Leveraging AWS CLI Credentials Stored in

A Nodejs project has been set up with media files stored in an S3 Bucket and utilizing the @aws-sdk/client-s3 as the AWS SDK Client. The project consists of two important files, namely .env and S3Bucket.js. The content of .env (located in the root directo ...

Struggling to make sweetalert2 ajax function properly

Struggling with ajax - I'm determined to learn it, but it seems to be playing hard to get :) Take a look at my code below: <script> $('._givePP').on('click', () => { swal.mixin({ input: 'text ...

Incorporating the parent object into a nested JavaScript function

I have come across similar questions, but my situation seems unique to me. I have simplified my code and turned one line into a comment, but the core concept remains unchanged... function myFunction(options) { var button; options.widgets.forEach(f ...

Algorithm that continuously increases a given date by 3 months until it surpasses or matches the specified creation date

I am currently working with QuickBase, a platform that involves HTML. My goal is to develop a code that can take a [fixed date] (always in the past) and increment it by 3 months until the MM/YYYY exceeds or equals the MM/YYYY of the [creation date]. Once t ...

The presence of ng-show dynamically adjusts the minimum height of a div element

I am encountering an issue with a div that has the class of wrapper. Inside this div, there is a parent div with the class of content-wrapper. The wrapper div includes a conditional directive ng-show which toggles between displaying or hiding its content. ...

Retrieving information from a function beyond the scope of Mongoose

I am currently facing an issue with my function in which I need to return the Mongoose query data so that I can use it. However, I am only able to access the sum within the .exec function. How can I manage to retrieve the sum value outside of this functi ...

Create automated scripts with Selenium using the programming language JavaScript

Is it possible to create selenium webdriver scripts using only javascript? If so, what are the benefits of choosing javascript over languages like java or C#? In what situations would javascript be the preferred option? Appreciate your insights. ...

In an empty JavaScript MVVM Organization View, the ViewModel is packed with lines of code

I find myself always placing all of my code within the ViewModel because nothing else seems to fit. What kinds of things should be included in the view? Does anyone have any examples? ...