So it is a bit odd how a small accompaniment can go a long way.
Today I decided to get back into the thick of things and try and learn more on JavaScript and to my surprise it is working, In the past I never thought I would be able to do something with JS but today I believe I can great great things with it.
Now to anyone that sees this note what I have done well not much. It is just me wanting to learn how to use JS with my php work and thought to give it another go the past has given me some issues but for not I am happy with the small thing I have done.
What is it you may ask? Well just some AJAX to add on a button push.
Code bellow
Index.html
</p><p><!DOCTYPE html><br /> <html><br /> <head><br /> <meta charset="UTF-8"><br /> <title>Learn JavaScript</title><br /> <script type="text/JavaScript"><br /> function TimeisIt()<br /> {<br /> var xmlhttp;<br /> if (window.XMLHttpRequest)<br /> {// code for IE7+, Firefox, Chrome, Opera, Safari<br /> xmlhttp=new XMLHttpRequest();<br /> }<br /> else<br /> {// code for IE6, IE5<br /> xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");<br /> }<br /> xmlhttp.onreadystatechange=function()<br /> {<br /> if (xmlhttp.readyState==4 && xmlhttp.status==200)<br /> {<br /> document.getElementById("myDiv").innerHTML=xmlhttp.responseText;<br /> }<br /> }<br /> xmlhttp.open("GET","SS.php",true);<br /> xmlhttp.send();<br /> }<br /> </script><br /> </head><br /> <body><br /> <a href="#" onclick="TimeisIt()">What Time is it?</a><br /> <div id="myDiv"></div><br /> </body><br /> </html><br />
SS.php
</code></p><p><code><?php<br />session_start();<br />//echo "Hello it is ".date("g:i a");<br />if(isset($_SESSION['num'])){<br /> $_SESSION['num']++;<br />}else{<br /> $_SESSION['num']=1;<br />}<br />echo $_SESSION['num'];</code></p><p><code><br />?></code></p><p>