php - acess denied in joomla when call through ajax -
i have joomla ajax based modules fetching data db. want use script fetching data db
$db = jfactory::getdbo(); $db->setquery("my query"); $db->query(); $res = $db->loadassoclist();
but give me error
fatal error: class 'jfactory' not found in
then put code @ top of page
defined( '_jexec' ) or die( 'restricted access' );
to enable jfacotry , enabled expected can not enter page recieve message "restricted access".
what should on come problem.
as understand question want use joomla methods in external file , call file data through ajax. if correct, wold default joomla environment can call external file function directly module. can not use joomla method directly fetching result database without including library files.
suggestion : 1 thing works me while having same problem. have made custom component , define task in it, fetch data database , call task in module through ajax , show result. thing works me.
try make ajax call custom or existing component controller below.
<script> jquery.ajax ({ type: "get", url: "index.php?option=com_custom&controller=custom&task=getdata", data: data, success: function(data) { alert(data) } }); </script>
hope suggestion solve problem. luck.
Comments
Post a Comment