javascript - Function behaving differently when being called from different form -
i using ajax create phone call on server, , function behaving differently depending on calling from. here snippet of code in question:
<html> <body> <script> function showhint(str) { var xmlhttp; alert("call made"); if (str.length==0) { document.getelementbyid("txthint").innerhtml=""; return; } if (window.xmlhttprequest) {// code ie7+, firefox, chrome, opera, safari xmlhttp=new xmlhttprequest(); } else {// code ie6, ie5 xmlhttp=new activexobject("microsoft.xmlhttp"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readystate==4 && xmlhttp.status==200) { document.getelementbyid("txthint").innerhtml=xmlhttp.responsetext; alert(xmlhttp.responsetext); } } xmlhttp.open("get","myajax.php?q="+str,true); xmlhttp.send(); } </script> <form action=""> first name: <input type="text" id="txt1" onkeyup="showhint('hey')" /> </form> <p>suggestions: <span id="txthint"></span></p> <tr><td><a href=/upload/actionscript.xml>actionscript.xml</a></td><td>0.03 mb</td><td>june 17 2014 11:29:29</td><td> <a href='' onclick="showhint('hey')" /> <img src="images/trash.png" alt="delete" width="25" height="25"></a></td><tr> </body> </html> so when type in text field, works , should, gets thought both alerts. when click on href, alert popping "call made". reason this
remove forwards slash(/) in <a /> .. </a>
<!-- remove slash --> <a href='' onclick="showhint('hey')" /> <img src="images/trash.png" alt="delete" width="25" height="25"> </a> javascript php jquery html ajax
No comments:
Post a Comment