Chat with simple autoload

Share your ideas & teach other
Post Reply
samuel_anttunes
Posts: 29
Joined: Thu Mar 09, 2023 12:25 pm

Chat with simple autoload

Post by samuel_anttunes »

Simple system. Create a page in JSON format and create a JSON structure. Inside the page you must pass the information that must present in JSON that we will read in a script ( You can use either the DATA API or POST LIST, taking this information and docking in JSON ). On the chat page we will do the following script .

Let's create a function and call our page with the JSON data we just assembled. That was a method I used.
https://www.w3schools.com/js/js_json_html.asp
has other ways to call the file and present it in a Div. After the function is configured I will make it update every 1 second using this method.
https://www.w3schools.com/jsref/met_win_setinterval.asp

at the end so it should stick the structure.

Code: Select all

 <script>
setInterval(chat, 1000);

function chat() {
 
 const dbParam = JSON.stringify({table:"customers",limit:4});
const xmlhttp = new XMLHttpRequest();
xmlhttp.onload = function() {
  const myObj = JSON.parse(this.responseText);
  let text = "<ol class='chat'>"
  for (let x in myObj) {
    text += " <li class="+ myObj[x].quem +"><div class='msg'>" + "<font color='black'>"  + myObj[x].name + " : " + " </font>" +  "<p>" + myObj[x].content +  "</p>" +  "</br>" + "<time>" + myObj[x].time + "</time>" + "</div><hr/></li>";
  }
  text += "</ol>"    
  document.getElementById("chat").innerHTML = text;
}
xmlhttp.open("GET", "/message page in Json.html");
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.send("x=" + dbParam);
 }
</script>
</script> 


Use this div to call the chat

Code: Select all

 <p id="chat"></p> 
And a simple structure, soon new updates. Check out my website: https://godcode.wapka.xyz/

-----------------------NOTE-----------------
Remember when you are creating the page with json information, you must create an array list with multiple objects. See the example of my https://hlsking.wapka.site/msg.
Jhoan
Posts: 2
Joined: Thu Mar 09, 2023 5:25 am

Re: Chat with simple autoload

Post by Jhoan »

Code Complet please...
zunaid
Posts: 5
Joined: Tue Mar 07, 2023 9:08 am

Re: Chat with simple autoload

Post by zunaid »

built in json API is under development check https://core.wapka.org
samuel_anttunes
Posts: 29
Joined: Thu Mar 09, 2023 12:25 pm

Re: Chat with simple autoload

Post by samuel_anttunes »

Jhoan wrote: Sat Mar 11, 2023 2:19 am Code Complet please...
https://cdn.wapka.org/009362/662e1b494a ... ochat.json
samuel_anttunes
Posts: 29
Joined: Thu Mar 09, 2023 12:25 pm

Re: Chat with simple autoload

Post by samuel_anttunes »

zunaid wrote: Sat Mar 11, 2023 8:14 am built in json API is under development check https://core.wapka.org
It will take a while yet to release new features. When we launch we update the tutorial since api tbm works with JSON .
Jhoan
Posts: 2
Joined: Thu Mar 09, 2023 5:25 am

Re: Chat with simple autoload

Post by Jhoan »

samuel_anttunes wrote: Sat Mar 11, 2023 1:46 pm
Jhoan wrote: Sat Mar 11, 2023 2:19 am Code Complet please...
https://cdn.wapka.org/009362/662e1b494a ... ochat.json
Thank you
premy1172@gmail.com
Posts: 1
Joined: Wed Apr 26, 2023 7:00 am

Re: Chat with simple autoload

Post by premy1172@gmail.com »

Dosto chatting forum kese creat karna hai koi batao plz wapka.site me chartting code kya hai aur o kaha dalna hai plz help me
samuel_anttunes
Posts: 29
Joined: Thu Mar 09, 2023 12:25 pm

Re: Chat with simple autoload

Post by samuel_anttunes »

To use forum chat, just swap the api list for the forum list. I've seen some adaptations.
Pin2
Posts: 5
Joined: Tue May 02, 2023 11:03 am

Re: Chat with simple autoload

Post by Pin2 »

Same problem bro ? :roll:
Post Reply