Page 1 of 1

Chat with simple autoload

Posted: Fri Mar 10, 2023 1:40 pm
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.

Re: Chat with simple autoload

Posted: Sat Mar 11, 2023 2:19 am
by Jhoan
Code Complet please...

Re: Chat with simple autoload

Posted: Sat Mar 11, 2023 8:14 am
by zunaid
built in json API is under development check https://core.wapka.org

Re: Chat with simple autoload

Posted: Sat Mar 11, 2023 1:46 pm
by samuel_anttunes
Jhoan wrote: Sat Mar 11, 2023 2:19 am Code Complet please...
https://cdn.wapka.org/009362/662e1b494a ... ochat.json

Re: Chat with simple autoload

Posted: Sat Mar 11, 2023 1:49 pm
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 .

Re: Chat with simple autoload

Posted: Sat Mar 11, 2023 1:59 pm
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

Re: Chat with simple autoload

Posted: Wed Apr 26, 2023 7:06 am
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

Re: Chat with simple autoload

Posted: Thu Apr 27, 2023 2:27 am
by samuel_anttunes
To use forum chat, just swap the api list for the forum list. I've seen some adaptations.

Re: Chat with simple autoload

Posted: Fri May 05, 2023 3:07 am
by Pin2
Same problem bro ? :roll: