javascript - Ajax post opens a new window after submitting -


i'm trying submit form , response using ajax, when submit form new window opened values typed
function works , should, it's new window problem
here html code :

<head>     <meta http-equiv="content-type" content="text/html; charset=utf-8" />     <link href="chat_style.css" rel="stylesheet" type="text/css"> </head> <body> <div id = "refresh" class="refresh"></div> <form method="post" action="save.php" name="chat_send"  onsubmit="sendchatdata(); return false;">     <input id="sender" name="sender" type="hidden" value ="<?php echo $sender ?>">     <?php echo "$sender:" ?> <input name="texta" type="text" id="texta"/>     <input name="submit" type="submit" value="send" /> </form> 

and js code :

function sendchatdata() {      var xmlhttpreq = false;     var self = this;     if (window.xmlhttprequest) {         self.xmlhttpreq = new xmlhttprequest();     }     else if (window.activexobject) {         self.xmlhttpreq = new activexobject("microsoft.xmlhttp");     }      self.xmlhttpreq.open('post', 'save.php' , true);     self.xmlhttpreq.setrequestheader('content-type', 'application/x-www-form-urlencoded');     self.xmlhttpreq.onreadystatechange = function() {         document.getelementbyid("texta").innerhtml = "";         if (self.xmlhttpreq.readystate == 4) {             var x = self.xmlhttpreq.responsetext;         }     }     self.xmlhttpreq.send(getquerystring()); }  function getquerystring() {     var qstr = "message=";     try {         qstr += document.getelementbyid("texta").value;         window.open(qstr);     } catch (e) {         // empty...     }     return qstr; } 

in code, have call window.open. - opens new (browser) window!

function getquerystring() {     var qstr = "message=";     try {         qstr += document.getelementbyid("texta").value;         window.open(qstr);   // <-- - opens new window!     } catch (e) {         // empty...     }     return qstr; } 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -