Fetch data (messages) in every second with ajax (setinterval) from mysql (PHP) in wordpress. In main file <script> jQuery(document).ready(function($){ var own_id = $("#own_id").val(); var user_id = $("#user_id").val(); alert('helo'); function sandeep(){ var data = { 'action':'fetch_message', 'own_id':own_id, 'user_id':user_id, } $.post(myajax.ajaxurl,data,function(response){ //$("#response").html(response); $("#jassi").html(response); console.log(response); }); } setInterval(function(){ sandeep(); }, 500); }); </script> <div id="jassi"> </div> In Funtion.php file function fetch_message(){ $msg_content = $_POST['msg_content']; $own_id = $_POST['own_id']; $user_id = $_POST['user_id']; echo $user_id; global ...
We provide knowledgeable blogs related to php, jQuery, html, css, wordpress, woocommerce, cordova app with examples in 2021.