Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The other two were onto the right track you need to remember that when you make your AJAX call you can't directly access a php file in Joomla. So instead it's better to make calls to your module. In this case and have the module check for variables in your POST or in the URL. </p> <p>I'm a big fan of JQuery's ajax it's a lot more self contained than the method the guy who built that shoutbox used.</p> <pre><code>$( "#addShout" ).click( function(event, ui) { $.ajax({ type: 'GET', url: "&lt;?php echo JURI::base() . "index.php?option=mod_mymodule&amp;task=getCustomerJson&amp;selectedCustomer="?&gt;" + encodeURIComponent(value), success:function(data){ $('#shouts').append(data); }, error:function(){ $('#errors').html('&lt;p class="error"&gt;&lt;strong&gt;Oops!&lt;/strong&gt; Try that again in a few moments.&lt;/p&gt;'); } }); }); </code></pre> <p>Then as I mentioned in my comment to Valentin you:</p> <pre><code>$task = JRequest::getVar('task'); if($task == "getCustomerJson"){mySuperHelper::getCustomerJson();} </code></pre> <p>You only call the necessary functions when the variables exist. </p> <p>To explain part of the process it's kinda like this:</p> <ol> <li>If there are no variables in the POST or URL it will simply display the module the way Joomla expects.</li> <li>If the variable are detected call the method to add it to the database and the javascript function that will add it the the display. Also prevent the normal display from happening. </li> </ol> <p>The module you referenced was quite interesting. The helper functions that the main file referenced does what a model would normally handle in MVC and the Javascript was also kinda all over. If you really want to understand how that one worked you really need to dig into the fatAjax.js file as it contains all of the AJAX and sets the variables that the mod_shoutbox.php listens for. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload