JS Plugin syntax error - attempting to call php

VickiD

New Member
Hi,
I attempted to follow the example in user_ajax_example.php -which says to place the following snippet into the JS for the plugin
your custom JS code:
index.php?option=com_fabrik&format=raw&task=plugin.userAjax&method=userExists&username=" + myUsername;

* Fabrik will automatically try and call the function name specified in your 'method='.

The string is not valid JS and presents an error - I'm sure there is something very obvious that I am missing. Is there any help for a newbie like me?
P.S. what I am trying to do with the js plugin is use the button to call php which will take the row id and update or insert a record into a non-joomla database (external database) table and then it would be super to echo back to the user that it worked.

Thank you in advance,
Vicki
 
Hi Vicki
I've moved this thread to the Standard support section. You mailed saying you were unable to post here so I suggest you log out, and log in at http://fabrikar.com to ensure your credentials are up to date.

Could you post all of your javascript code or preferably a link to the page generating the error, at a guess I would say you are missing the inital quote before index.php, so it would be something like

Code:
var url = "index.php?option=com_fabrik&format=raw&task=plugin.userAjax&method=userExists&username=" + myUsername;

but without seeing the page its hard to be sure

-Rob
 
Hi Rob,
I am developing on Xampp localhost and likely will not have the site up when you are looking at this.
I downloaded the jslist plugin again and updated the plugin and made a change to the js code in the plugin. You were exactly right I did not have the opening quote on the Url. The error was resolved and I was able to execute code from the button generated when I added the plugin to a list. Basically, it runs without error - yea! But it doesn't appear to be doing anything -- drat foiled again.
the JavaScript Code in the plug-ins setting screen in the backend is as follows:

var url = "index.php?option=com_fabrik&format=raw&task=plugin.userAjax&method=VoteToBuy";

I am attempting to call a stored procedure in the php function I added to user_ajax.php. (attached)
I also created a function called echotest and was able to call it. My challenge is now I don't get an error but nothing is returned and in the case of calling the function with the stored procedure, the stored procedure does not execute. I tested the stored procedure from php I used in a generic Joomla module mod_callsp.php - (attached).
My two questions are: 1-should the echo value from user_ajax.php be returned to js-min.js (the caller)? 2-do you see any reason that the stored procedure sp_UpdInsVote would fail and not report an error in user_ajax.php?
Thank you
Vicki
 

Attachments

  • user_ajax.zip
    3.5 KB · Views: 193
As Rob said, we really need to be able to see the page, and log in to your site, to answer questions like these. It's almost impossible to just scan someone's code and spot an error, unless it's glaringly obvious - in which case you would probably have spotted it. And reproducing your setup on our local test systems to test is something we can only do at the Pro level of support, as it is very time consuming.

However ... I do recall there are issues with running stored procedures with the standard J! database API, which are hard to replicate in simple test setups, to do with freeing of resources.

So does your code even return an error number? Although using getErrMessage() (I think, I always forget the exact name of that one, might be getErrorMsg) is usually more useful.

Are you using Firebug in Firefox, so you can see (in the Net tab, in the Response from your AJAX call) whatever your code is tossing out?

-- hugh
 
FYI, I don't se any obvious PHP errors, so I suspect it is a stored procedure call issue.

Also ... I'm assuming you are positive that you have the ID (2) correct for the getDbo() call, that you have a connection in Fabrik with that ID?

-- hugh
 
Hi Rob and cheesegrits,
Thank you for your help. I have moved my site to a vps server and I have been working to understand my problem. It is clear to me now what I'm doing wrong - I failed to include code in JS to call mootools or some such mechanism to invoke the ajax function. Essentially, I wasn't calling a request.

I have a couple of clarifying questions in the hope that I can figure out how to do it right.
1) Example user_ajax.php says the AJAX js Mootools class should be called from the onchange trigger of a text element. Using the JS plugin creates a button I don't see it as an element. Do I need to also create a text element and add Js to that?

2) in the drop down to select JS File I did not select anything but I can see in firebug that js-min.js runs just before I get an undefined error. I put my js in the body of the plug-in. Do I have to do something with Js-min.js?

3) ideally is there an example with js / and php with the values used on the plugin and code in js? That is a big question I know = but I thought I'd ask.
Thank you,
VickiD
 
Just a quick update --
I found and watched the tutorial on custom Ajax interaction.
That must be an older version of Fabrik - I am attempting to work with JOOMLA 3 and Fabrik 3.1. The mootools js example results in the error
Ajax is undefined.
 
My previous comment sill applies - it's almost impossible to help with custom code involving AJAX and PHP both, without seeing your page.

Yes, that tutorial was written for Moo 1.2, we're now on Moo 1.4. See the comments in user_ajax_php, which gives you an example which should work on 1.4, which uses Request() instead of Ajax().

Anyway, get me access to your site. I'll need a super admin backend login, and sufficient details to get me logged in on both front and back ends, find the right list/elements, find the right link on the front end, etc. Ftp details would also help, or at least have exTplorer installed so I can edit your user_ajax if I need to.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top