Joomla how to make an ajax call to an helper.php module

后端 未结 2 1845
遇见更好的自我
遇见更好的自我 2021-01-24 06:14

I create a module, not a component, a module because it should appears a number of times, on a number of pages in various positions I follow basic module creation

In de

2条回答
  •  遇见更好的自我
    2021-01-24 06:51

    so after some ggsearch, I succeeded thanks to this post

    you have to call itself, best way to do is to use (in default.php):

     'url: "",'
    

    Then is mod_yourmodule.php intercept get or post "query" with JRequest::getVar because "$_POST['xxx']" does not work

     '$task = JRequest::getVar('task'); '
     'if($task == ....... '
     'and call the helper modyourmoduleHelper::youfuncion'
    

    In helper, as you don't need all layouts I sent an echo of funcion returned value between “<”reply“>” tags and stoped joomla with jexit()

    The reply will be the default.php + the echo easily parsed with :

     'var re = /(.*)<\/reply>/;'
     'var result = re.exec(T_output);       '       
     'if(result[1] != ''){ Displayfunction($.parseJSON(result[1]));}'
    

    ... finished

提交回复
热议问题