Thanks. What does " return function () {" mean? This is what I worked out:
PHP Code:
<?php
$name = $_GET['name'];
echo $name;
?>
HTML Code:
<head>
<script type="text/javascript">
function display(el) {
var type="";
if (el.innerHTML == 'Send to Cart') {
el.innerHTML = 'Sent to Cart';
type="sent";
} else {
el.innerHTML = 'Send to Cart';
type="send";
}
if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
} else { // code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
alert(xmlhttp.responseText);
}
}
console.log(el.name);
xmlhttp.open("GET","test99.php?name="+el.name,true);
xmlhttp.send();
}
</script>
</head>
<body>
<button name="jasmine" type="button" onclick="display(this)">Show Date</button>
</body>
</html>
Bookmarks