Hai foks, i could not figure out whats wrong with my ajax code. the mail is not sent. <script language="javascript"> function submitform(){ var xmlhttp; 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); alert("Success"); } } var name=document.getElimentById("name").value; var email=document.getElimentById("email").value; var message=document.getElimentById("message").value; xmlhttp.open("POST","sendmail.php",true); xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded'); xmlhttp.send("name=name&email=email&message=message"); } </script> PHP: but without this part it works var name=document.getElimentById("name").value; var email=document.getElimentById("email").value; var message=document.getElimentById("message").value; Code (markup):
Hai buddy, yes ofcase !!! Thank you so much. then i have another small problem. var name=document.getElementById("name").value; var email=document.getElementById("email").value; var message=document.getElementById("message").value; xmlhttp.open("POST","sendmail.php",true); xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded'); xmlhttp.send("name=name&email=email&message=message"); Code (markup): is this line syntax above correct? xmlhttp.send("name=name&email=email&message=message"); Code (markup): cos i dont get variable values
it is incorrect. you need to break up that string. xmlhttp.send("name=name&email=email&message=message"); should be xmlhttp.send("name="+name+"&email="+email+"&message="+message); or something like that