I'm using an external ajax file to perfom an ajax call inside a module.( i didnt want to edit controller or make a subcontroller just for one call )

$(document).on('click', '.changeBtn',function(){
  var yo="<?php echo 'ip_searchmod_'.$unique_qsid; ?>";
  var text="<?php echo JText:: _('COM_IPROPERTY_THANASIS_ADV_SEARCH');?>";

    success: function(response){

      $('#' + yo).html(response);
      $('#' + yo).addClass('formSwapper');



Ajax is working peftectly , my problem is that im using this JText:: _('COM_IPROPERTY_THANASIS_FOR_SALE'); inside the ajax file and it is echoed like : COM_IPROPERTY_THANASIS_FOR_SALE instead of For Sale . On the default.php file of module that language definition is working perfectly but not inside ajax file.

I tried to use language override from joomla administrator but it didnt work.

Inside ajax file i use the following includes:

require_once( JPATH_BASE . DS . 'includes' . DS . 'defines.php' );
require_once( JPATH_BASE . DS . 'includes' . DS . 'framework.php' );
require_once( JPATH_BASE . DS . 'libraries' . DS . 'joomla' . DS . 'factory.php' );

Do i have to include anything more for it to work ?

1 Answer 1


After you're require_once calls, add the following to initialise the applications:

$mainframe = JFactory::getApplication('site');

Then load the component's language file:

$lang = JFactory::getLanguage();
$lang->load('com_iproperty', JPATH_ROOT);

I have guessed com_iproperty, so if it's not correct, please change it.

  • No No the JText im using inside jquery is working fine ! The faulty JText is an echo inside the ajax file!
    – IseNgaRt
    Nov 2, 2015 at 9:44
  • @IseNgaRt - Is the Ajax file a PHP or JS file?
    – Lodder
    Nov 2, 2015 at 9:46
  • It is a PHP file
    – IseNgaRt
    Nov 2, 2015 at 9:46
  • Ok, in your Ajax file, please add <?php var_dump(JPATH_BASE); exit; ?>. In your console log, this should display a URL or null. Please let me know what the result is
    – Lodder
    Nov 2, 2015 at 9:48
  • string(36) "/var/www/vhosts/spiti360.gr/httpdocs" Its the root folder of the site
    – IseNgaRt
    Nov 2, 2015 at 9:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.