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 9079205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:47:17+00:00 2026-06-16T19:47:17+00:00

I am creating a basic Php Ajax chat application. when i am using this

  • 0

I am creating a basic Php Ajax chat application.

when i am using this basic application on my own PC in cross browser(means in one time chrome and Mozilla assuming two person) is working fine. but when i am using this application on cross PC means one man is chatting from one PC and another man is chatting from 2nd PC then it is not working..

Problem : send chat content from one PC is receiving on 2nd pc
but from second PC (chat Reply) send chat content is not receiving

 Ajax response is not coming using `set Interval` and browser is not refreshing..

Code :

J query

setInterval(function() { 
   $.ajax({
     url: "http://192.168.1.13/naresh/ajaxchat/chatsave.php?q=getChat",
     success: function(response) {
        $("#ulShowChatContent").append(response);
         }
    });
}, 1000);

Php

function getChat(){
        $useremail  = $_SESSION['email'];
        $sqlGetUserInfo = mysql_query("select * from  users where email = '$useremail'") or die(mysql_error());
        if(mysql_num_rows($sqlGetUserInfo)>0){
            $userInfo = mysql_fetch_array($sqlGetUserInfo);
            $userId = $userInfo['id']; 
            $currentdate =  date('Y-m-d H:i:s');

            $sqlGetChatContent = mysql_query("select chat_id,chat_content,name from pvt_chat 
                                                INNER JOIN users ON pvt_chat.userid = users.id 
                                                where pvt_chat.userid != '$userId' 
                                                and receive_status = 0
                                                and send_datetime <= '$currentdate' 
                                                ORDER BY send_datetime DESC limit 1") or die(mysql_error());

            if(mysql_num_rows($sqlGetChatContent)>0) {
                $resGetChatContent = mysql_fetch_array($sqlGetChatContent);
                $receiveChatId = $resGetChatContent['chat_id'];
                echo '<li>'.$resGetChatContent['name'].' says : '.$resGetChatContent['chat_content'].'</li>';
                $sqlUpdateRecStatus = mysql_query("UPDATE pvt_chat SET receive_status = '1' WHERE chat_id ='$receiveChatId'") or die(mysql_error());
            }
        }
    }
  • 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-06-16T19:47:18+00:00Added an answer on June 16, 2026 at 7:47 pm

    My question to you: what web page (+ domain) is PC2 using to access the chat? If the page is accessed from his localhost or any domain/IP other than 192.168.1.13 you have a cross-domain issue.
    Browsers today block AJAX calls to webpages on another domain (and even subdomain and port has to be the same IIRC) for security reasons. If PC2 is accessing the webpage from http://localhost/chatPage.html (for example), then he cannot make a request to “http://192.168.1.13” in the AJAX call.

    Some solutions:

    • Host the chatpage on the same server as where your AJAX calls are originated from (so that the domain of the chatpage is the same as the domain of the AJAX call)
    • Use a JSON response and convert it to HTML in the browser. There is a workaround for cross-domain issues when you’re using JSON, but that means that you have to convert the JSON output to HTML by yourself. You also need to make sure that you put the attribute dataType: 'jsonp' in your AJAX call.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a basic form with ajax submit using jquery framework. This is my
I'm creating my own template engine using PHP. The basic idea is that for
I am using the Grails ajaxflow plugin for creating a basic wizard. One issue
I'm creating a basic blog CMS using PHP MySQL jQuery, Below is my MySQL
I am creating a fairly basic login form using PDO for the first time.
I'm creating a standard 'framework' in PHP for my own projects. On this point
I'm planning on creating a small web app using PHP. The last time I
Right now I'm stuck between using PHP's native session management, or creating my own
I'm creating some basic OO scripts using MySQLi and getting an Undefined Method error
Using jQuery I'm creating a basic 'tooltip' animation so that the tooltip will appear

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.