Basic Ajax query

Status
Not open for further replies.

chozma

Member
Hi everyone,

I am new to Fabrikar and whilst I have a background in computer science I haven't coded properly for the last 7 years and have no serious experience of Ajax, Javascript or PHP (but lots in Java, C and HTML/CSS). So I get the concepts of all of this just not sure of the specifics of it all.

I am messing around trying to get Ajax to work today. For now I want to do a very simple thing which is when a field in a form is changed the text below it updates with a set string. A bit like the ajax example but even more simple.

I went through the video tutorials but then of course realised how out of date they were *doh*! So have been working with the code snippets provided in the example and on the wiki.

So I have an element in a form which the javascript is to kick in on when there is a change. The javascript I have put in is:

Code:
var url = "index.phpoption=com_fabrik&format=raw&task=plugin.userAjax&method=testTest";
 
new Request({url:url,
method: 'get',
update: document.id('user_ajax_example___Extra_info')
}).send();

Then I have taken user_ajax_example.php and renamed it to user_ajax.php. Then within that I have the following code:

Code:
<?php
// No direct access
defined('_JEXEC') or die('Restricted access');

class UserAjax
{
    public function testTest()
    {
       $retStr = 'Ha ha ha';
       echo $retStr;
    }
}

Using firebug I can see that the ajax request is working but the response is the following:
Code:
<br />
<b>Notice</b>:  Undefined index: form in <b>C:\xampp\htdocs\joomla30\libraries\legacy\view\legacy.php</b> on line <b>425</b><br />
<br />
<b>Warning</b>:  Creating default object from empty value in <b>C:\xampp\htdocs\joomla30\components\com_fabrik\views\form\view.base.php</b> on line <b>57</b><br />
<br />
<b>Fatal error</b>:  Call to undefined method stdClass::getForm() in <b>C:\xampp\htdocs\joomla30\components\com_fabrik\views\form\view.base.php</b> on line <b>58</b><br />

I have Joomla installed on my machine and am running it all locally.

I know this has to be something really simple but I can't see what's up! Any help would be appreciated to get me going.

Kind regards,

Hannah
 
After spending most of the afternoon trying to fix this is seems I missed a ? from the url line. It should have been:

Code:
var url = "index.php?option=com_fabrik&format=raw&task=plugin.userAjax&method=testTest";
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top