Hot answers tagged

4

Playing with the sessions is usually not a very safe thing to do - you could create more problems by trying to find a solution. You can do one (or both) of the following: Increase the Session Lifetime under System, Global Configuration to a higher number, such as 1440 (1 day). This will minimize the problem, but will not eliminate it. Another problem with ...


4

You can use JSON format in the controller directly by adding .json suffix and changing format in your URL to json. In this case the controller would be placed in /administrator/components/com_example/controllers/ajax.json.php. It's contents: defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Response\JsonResponse; class ExampleControllerAjax ...


3

One way I can imagine to check the session is before you ignite the above ajax call, you make a previous ajax call to another function in com_contract/controller(task = your new session checking function. so: url:...com_contract/task=checkSession) where you create a function, something like: public function checkSession() { try { $session1 =...


3

This component is developed using Akeeba FOF, so you need to read the documentation to know how to complete the task. Almost everything is configured using XML, this is to some extent of course. To add the onchange javascript code to the dropdown list: https://github.com/akeeba/fof/wiki/XML-Form-Fields#additional-attributes-for-drop-down-list-fields Also, ...


3

First, since you want to send just an extra key+value, then you can include that in the url of the ajax call like the following: url: '/my_site/index.php?option=com_j2store&view=callback&task=callback&method=getModel&Itemid=' + selection, And I do not see why but if you want to send the chosen value with the key(sel-make), then: url: '/...


3

I wanted to answer your earlier question about this yesterday, but someone was already answered this partially for you. So according to me your original Login Form token field should be a bit changed like the following: <form method="post" action="#" id="userForm"> <label for="username">Brugernavn</label> <input type="text" ...


3

Apperently I was missing an important part. I needed to have the "loginUser" task addded to the switch in view.ajax.php like: function display($tpl = null) { $task = JRequest::getString('task'); switch( $task ){ case "registerNewUser": $this->_registerNewUser( JFactory::...


2

Maybe I misunderstand you in your question but in the directory of com_content/views/article you cannot/should not create a view.html.php file since it originally has a good view.html.php file. In the tutorial which you follow the author says that you should create an 'view.ajax.php' file in com_content/views/article folder (not a view.html.php file). ...


2

As you just begin to develop a joomla component you really got into a heavy duty job right away. J2Store is a quite well built component (I like that and use that), however it's built with using FOF (and on the top of that, with the old FOF and by a quite advanced developer guy). So you will have few additional things to study and a bit of a headache too (...


2

well after the valuable help of @Zollie I will post the answer and working code to help others. A sample of the template file : <form action="<?php echo JRoute::_('index.php?option=com_contract&view=contracts'); ?>" id="adminForm" method="post" name="adminForm"> <?php if (!empty($this->items)) { ?> <div class="...


2

To get the session state, you can use the following: JFactory::getSession()->getState(); I'm not sure if this script is inline or a separate file. If it's inline then you can simply add the following to your Javascript: var sessionState = '<?php echo JFactory::getSession()->getState(); ?>'; if (sessionState === 'expired') { // redirect to ...


1

If you still want to use the frontend urls from backend, make sure to call the frontend site appropriately. Your should use Juri::root() to get site url from administrator instead of Juri::base() or Juri::current(). Juri::root() --> http://mysite.local Juri::base() --> http://mysite.local/administrator Juri::current() --> http://mysite.local/...


1

Only components that specifically provide a JSON response are accessible in the JSON format. Modules are not (by design) directly addressable hence you can not call them directly, therefore, no JSON format option. You could build a plugin to gain access to the data you wanted but that would be a 100% custom built option.


1

When my helper.php file passes data back to the ajax call, with: echo new JResponseJson($response); I parse the response like this: .success(function (result) { result = JSON.parse(result); Then you can access HTML data with: result.data.HTML Relevant resource: https://docs.joomla.org/JSON_Responses_with_JResponseJson When I first "came to Joomla" ...


1

Looks like the url in your Ajax call is wrong. You shouldn't use the controller as a var in the url but as prefix followed by the task. Also after the "?" goes the option and then the rest of url vars. Try to Replace : url: "index.php?format=raw&option=com_j2store&controller=products&task=doSomething", With url: "index.php?option=...


1

Regarding your ajax call to the json generating contoller, method is the more modern term rather than type since JQuery 1.9 jQuery.ajax({ method: 'POST', // method is more modern than type url: 'index.php?option=com_daily&task=ajax.initialisePerson&format=json', data: registration, success: (function (response) { ... I haven't ...


1

How did you come up with the round brackets? The semicolon ist also wrong. Objects come with curly brackets and arrays with square brackets. Your string will work with the 2 issues corrected. The values can be accessed with response.userblock, response.fileName ... There is no "message" in the response, so you won't get anything there. You should use the ...


1

Your project only needs access to an array in json format. I'm more in the option 1 camp. Get your data once and never again. If you are worried about load on your database, there are work arounds for that. You could store a .json file of user handles -- completely ready to drop into your .js declaration. You could update the .json file whenever a new ...


Only top voted, non community-wiki answers of a minimum length are eligible