Ajax Demo not working live...

Status
Not open for further replies.

nickbunyan

Member
I have been struggling to use ajax/js as a way of showing a related image when choosing from a drop down list.

In desperation I copied the examples Felixkat provided in #23061 in their entirety, actually created the appropriate tables [lists] and cut and pasted the code word for word... Everything looks OK until selecting from the dropdown when I get an error:

Fatal error: Class 'plgFabrik_' not found in /var/www/vhosts/xxxxxxxxxxxx/httpdocs/components/com_fabrik/models/pluginmanager.php on line 297

I really do not know what to try next or how to diagnose further. Help Please.

Joomla 2.5.7 and very recent Github.
 
Debugging info...

Can you post a link to the thread you are mentioning (and your code)?

Hi Troester. The thread is number 23061 as I think I mentioned above...

Code samples and screenshot attached. The only changes I have made are the hostname and the image path replacements as I am not using a thumbs gallery...

Any help much appreciated.
NickB
 

Attachments

  • user_ajaxphp.txt
    3.2 KB · Views: 466
  • formeljs.txt
    615 bytes · Views: 407
  • Capture1.JPG
    Capture1.JPG
    34.9 KB · Views: 442
Hi Felix.
The image placeholder in the orders table is "image".
I copied the two table definitions exactly from the screenshots in your demo in the thread mentioned earlier.
NickB
 
Well I think when I originally did that chunk of code we didn't have the Display element, although I could be wrong, and the image element was the obvious element to use.

You don't actually need any element for the update to work just a DIV to update the refresh, however by creating an element it saves messing around with custom templates.

For the example here I have just used a display element literally to create the DIV space needed to refresh the data. That is to say it doesn't need any configuring.

http://dev.fabriking.com/dbjoin-ajax-test (Note this link may not alway be here for future people reading this post).

The js is:-

Code:
function getInfo()
{
    var elementid = $('customerorders___name').getValue();
    var url = 'index.php?option=com_fabrik&format=raw&view=plugin&task=userAjax&method=eleopts';
    new Request(
    {
        url: url,
        data: {
            method: 'eleopts',
            identify: elementid,
        },
        onComplete: function (r)
        {
            $('customerorders___display').innerHTML = (r);
        }
    }).send();
};
And the ajax which was adapted from another post at some point....

Code:
 <?php
defined( '_JEXEC' ) or die( 'Restricted Access' );
class userAjax
{
    function eleopts( )
    {
        $result   = '';
        $db       = JFactory::getDBO();
        $IdClasse = JRequest::getVar( "identify", "" );
        $result   = '<ul>';
        $db->setQuery( "SELECT * FROM customers WHERE id = '$IdClasse'" );
        $row    = $db->loadObjectList();
        $rows   = $row[ 0 ];
        $result = $result . '<li style="list-style-type:none;text-align:none;margin-right:8px;">' . $rows->address1 . '</li>';
        $result = $result . '<li style="list-style-type:none;text-align:none;margin-right:8px;">' . $rows->address2 . '</li>';
        $result = $result . '<li style="list-style-type:none;text-align:none;margin-right:8px;">' . $rows->town . '</li>';
        $result = $result . '<li style="list-style-type:none;text-align:none;margin-right:8px;">' . $rows->zipcode . '</li>';
        $result = $result . '<li style="list-style-type:none;text-align:none;margin-right:8px;"><img src="' . $rows->image . '" alt="Smiley face" height="42" width="42"></li>';
        echo $result . '</ul>';
    }
}
?>
This code is obviously updating a few rows and an image with inline styling but it's easy enough to add and remove what you need I think.
 
Hi again Felix...

OK. I have amended the element/list references and the script appears to be ok, as does the user_ajax... I have changed the element type to display as suggested and simplified the js slightly, and I WAS hopeful...

Except when I run it I get the same error reported at the top of this thread. If I use the debugger I 'seem' to be getting the right arg/values to pass to the user_ajax script so I am now completely at a loss as to how to debug. I can't even figure out where pluginmanager.php is being called, but I guess it is in form submission somewhere?

In case it is pilot error or a typo my actual scripts are below:

USER_AJAX.PHP

<?php
defined( '_JEXEC' ) or die( 'Restricted Access' );
class userAjax
{
function eleopts( )
{
$result = '';
$db = JFactory::getDBO();
$IdClasse = JRequest::getVar( "identify", "" );
$result = '<ul>';
$db->setQuery( "SELECT * FROM products WHERE id = '$IdClasse'" ); // assuming the key to the remote table is the default 'id'
$row = $db->loadObjectList();
$rows = $row[ 0 ];
$result = $result . '<li style="list-style-type:none;text-align:none;margin-right:8px;">' . $rows->product_name . '</li>';
$result = $result . '<li style="list-style-type:none;text-align:none;margin-right:8px;">' . $rows->product_description . '</li>';
$result = $result . '<li style="list-style-type:none;text-align:none;margin-right:8px;"><img src="' . $rows->product_image . '" alt="Smiley face" height="42" width="42"></li>';
echo $result . '</ul>';
}
}
?>


15.js

function getInfo()
{
var elementid = $('orders___product').getValue();
var url = 'index.php?option=com_fabrik&format=raw&view=plugin&task=userAjax&method=eleopts';
new Request(
{
url: url,
data: {
method: 'eleopts',
identify: elementid,
},
onComplete: function (r)
{
$('orders___display').innerHTML = (r);
}
}).send();
};


ANY advice or help much appreciated!
 
The only thing I can suggest first is to apply the latest Github as that's what I'm using.

You have to ensure that all files are updated and overwritten otherwise strange messages will appear if the files are out of sync.

I think only then can we start to debug the issue. :)
 
The only thing I can suggest first is to apply the latest Github as that's what I'm using.

You have to ensure that all files are updated and overwritten otherwise strange messages will appear if the files are out of sync.

I think only then can we start to debug the issue. :)

Updated to latest github. sadly, no change, same problem...
 
No change ...

The only thing I can suggest first is to apply the latest Github as that's what I'm using.

You have to ensure that all files are updated and overwritten otherwise strange messages will appear if the files are out of sync.

I think only then can we start to debug the issue. :)

Have updated to latest github and makes no difference sadly.
 
Felix.
can you please drop me a screenshot of the element definitions on the dev server just in case i am doing something stupid.. Thanks.
 
Can you post a screenshot of your database join settings.

Also your PHP version and memory settings.
 
Hi Felix.

PHP Version 5.3.17
Memory Limit set to 128M [I assume the PHP.INI one?]

Screenshot of element attached...
...and I should mention Hugh had a look last night and was attempting to reproduce I think.
NickB
 

Attachments

  • product_ele.jpg
    product_ele.jpg
    63.7 KB · Views: 402
Strange, nothing stands out with your code, PHP version, memory size or dbjoin settings.

What else is running on that form? Do you have any validations or any other additions? I don't think they would make a difference and I'm probably clutching at straws.... but it gives me time to ponder.
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top