Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm going to answer based on the limited information I've got to help you in the broadest way possible following industry standards. You need to not code in the way you currently are because it is very inefficient and quite frankly dangerous.</p> <p>Here is the mootools code required to run an intervaled polling (I've used Mootools as you said you're using Joomla, I've assumed you're using 1.6+ as 1.5 is EOL this month):</p> <pre><code>//this sets how often you want to update (in milliseconds). setInterval('chatPoll()',2000); //this function essentially just grabs the raw data //from the specified url and dumps it into the specified div function chatPoll() { var unixTimestamp Math.round(new Date().getTime() / 1000) var req = new Request({ method: 'get', url: $('ajax-alert').get('http://www.yoururltoupdate.com/file.php?last=' + (unixTimestamp-2), data: { 'do' : '1' }, onComplete: function(response) { response.inject($('my-chat-wrapper')); } }).send(); } </code></pre> <p>Your PHP file should look something look like this:</p> <pre><code>get_messages($_GET['last']); function get_messages($last_id) { $sql = 'SELECT * FROM #__messages WHERE `id` &gt;'.intval($last_id); $db-&gt;setQuery($sql); $rows = $db-&gt;loadAssocList(); if (count($rows)&gt;0) { echo json_encode($rows); } } </code></pre> <p>I haven't fully tested this code but it should work and if not will definitely help answer your query as to how what you're trying to do should be achieved rather than the way you originally posted. If you really wanted to get fancy you could check out node.js as well. There is also tons of extensions for Joomla which work as chat mediums for support purposes if that's what you were after.</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. 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.
    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