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