php - How i can prevent form from refreshing page after submit -
i'm using chat script internet,very simple , effective when press submit button refreshes whole page.i want refresh form not entire page because use tabs.i use 3 tabulators: workspace , chat, , news , when click chat opens tabulator , when click submit refresh whole page , starts workspace tab.
here code.
function ajax(){ var req = new xmlhttprequest(); req.onreadystatechange = function(){ if(req.readystate == 4 && req.status == 200){ document.getelementbyid('chat').innerhtml = req.responsetext; } } req.open('get','chat.php',true); req.send(); } setinterval(function(){ajax()},1000);
.chat_s { margin-top:20px; padding:20px; width:100%; height:200px; background-color: #f1f1f1; border-radius: 3px; } .chat_s textarea { width:400px; background-color:#f9f9f9; height:70px; border:none; resize: none; outline:none; font-size:13px; padding:20px; } .chat_s input[type=submit]{ background-color:#e7544a; color:white; height:30px; width:100px; margin-top:40px; display:block; }
<div class="chat_s"> <form id="chat_f" method="post" action="list.php"> <input type="hidden" name="name" value="<?php echo $user_name;?>"/> <input type="hidden" name="img" value="<?php echo $user_img;?>"/> <input type="hidden" name="role" value="<?php echo $user_role;?>"/> <textarea name="msg" placeholder="upisite vasu poruku."></textarea> <input type="submit" name="send_msg" value="posalji"/> <br/> </form> </div>
can me when user press submits refresh div.
Comments
Post a Comment