Hello I am new in ajax stuff and have a question
I have button with is sending data to my php script to save it… when ever I am clicking send button I am going there, I did put in the end return false it still doesn’t work.. Please can some one help here is my code…
var xmlHttp = false;
try {
xmlHttp = new ActiveXObject(“Msxml2.XMLHTTP”);
}
catch(e) {
try {
xmlHttp = new ActiveXObject(“Microsoft.XMLHTTP”);
}
catch(e) {
xmlHttp = false;
}
}
if (!xmlHttp && typeof XMLHttpRequest != ‘undefined’) {
xmlHttp = new XMLHttpRequest();
}
function sendData() {
if (xmlHttp) {
text = document.getElementById(“info”);
xmlHttp.open(‘POST’, ‘add.php’);
xmlHttp.setRequestHeader(‘Content-Type’, ‘application/x-www-form-urlencoded’);
xmlHttp.send(‘message=’ + text.value);
text.value = “”;
text.focus();
}
}
….
<form action=”add.php”>
<input type=”text” name=”info” /><br/>
<input type=”submit” onclick=”javascript:sendData();return false;” value=”Send”/>
</form>
Please help ?