• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

inconsistant return value from JScript

smart

Member
Hello,
When this JS run on the dropdown element and called the php ajax, the value return is coming for some data and not for other data.
Why is that? I copied those code from one QnA and edited.

JavaScript:
jQuery.ajax({
  url: 'index.php?option=com_fabrik&format=raw&task=plugin.userAjax&method=getSEQ&tid=' + this.getValue(),
  method: 'get',
  context: this
}).done(function (r) {
  /*debugger;*/
  IDShowTmp = r;
});

PHP:
class UserAjax
{

   public function getSEQ()
    {
        $db = FabrikWorker::getDbo();
        $query = $db->getQuery(true);
        $app = JFactory::getApplication();
        $input = $app->input;
        $TeaId = $input->get('tid', '');
        $query->select('MAX(kseqID)')->from('tk')->where('tid = ' . $db->quote($TeaId));
        $db->setQuery($query);
        $rett = ($db->loadresult())+1;
        echo $rett;
    }
 
The value from calc element returns normal.

PHP:
$db = FabrikWorker::getDbo();
$query = $db->getQuery(true);
$query->select('MAX(kseqID)')->from('tk')->where('ktid = {tk___ktid_raw}');
$db->setQuery($query);
$rett = $db->loadresult();
return $rett;
 
What I am trying to accomplish here is as follow.
When dropdown element is changed, its ID value will have to query the max sequence value (where)+ 1.
And some strings are added and set value to the link element value.
I tried to use sequence element but I don't know it could be used to get sequence on key value.
 
In your UserAjax file you have "tid" in where clause, but in your calc element code "tkid". Is it in purpose?

Do you get anything when you do:

Code:
...
}).done(function (r) {
alert(r);
});
 
I think I found the issue probably lack of knowledge as a beginner. lol.
From JS, I have set up three jQuery.ajax({}) call to userajax PHP; to get 3 values from separate tables. And also three global var are declared in JS to pass values in those three calls. That kind of setup might cause inconsistancy.
So now, I have set up just one call to PHP, get all values, place in a string with commas and return it back.
Then, split those in JS. Currently it is working without error.
I still have to learn a lot more for PHP, JS, html, CSS..

Thank you for your help, Juuser. :)
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top