Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7610457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:25:21+00:00 2026-05-31T01:25:21+00:00

I have made a simple chat script using jquery and AJAX but the huge

  • 0

I have made a simple chat script using jquery and AJAX but the huge hole in it is that i can only chat with myself properly 😛

heres the javascript for my main file

<script src="http://jqueryjs.googlecode.com/files/jquery-1.2.6.min.js"  type="text/javascript"></script>
<script type="text/javascript">
 $(document).ready(function(){

$("#status").load('ajaxLoad.php');
$("#userArea").submit(function(){
    var hr = new XMLHttpRequest();
var id = '<?php echo $id; ?>';
var name = '<?php echo $name; ?>';


var url = "ajaxPost.php";
var msg = document.getElementById("messages").value;


 var vars = "messages="+msg+"&id="+id+"&name="+name;
hr.open("POST", url, true);

hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
hr.onreadystatechange = function() {
    if(hr.readyState == 4 && hr.status == 200) {
        var return_data = hr.responseText;
        $("#status").append(return_data);
    }
}
hr.send(vars);
return false;});
 });

and heres my 2nd file “ajaxLoad.php”

<?php
include_once "connect_to_mysql.php";
$sql = mysql_query("SELECT messages,id FROM chat");
while($row = mysql_fetch_array($sql))
    {

echo $row["messages"];


    }
    ?>

Now what i need is to continually refresh “ajaxLoad.php” so that users can chat in realtime without refreshing the page…any way around this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T01:25:22+00:00Added an answer on May 31, 2026 at 1:25 am
    // reload every second
    setInterval(function() {
      $("#status").load('ajaxLoad.php');
    }, 1000);
    

    Be careful of making too requests to the server. It’s going to be rather intensive.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have started using jQuery and rails. I have made a simple form that
I have made a chat script using php, mysql and jquery. It uses json
I have made a simple, but relatively computationally complex, UDF that queries a rarely
I have made a simple web page using jQuery. When opening it on another
Hi, I have made this simple script but I need to have it check
I have made a simple accordion for my site using jQuery... It worked great,
I have a simple software that is made in Delphi 7, and it crashes
I'm learning java and I have made simple program that simply reads value from
I have made a simple plugin with a form but it won't post when
I have made a simple page for a sound board that I made. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.