Posted By

danhanly on 01/20/11


Tagged

mysql ajax php data variables send


Versions (?)

AJAX MySQL Query


 / Published in: JavaScript
 

  1. function sendProject(){
  2.  
  3. if (window.XMLHttpRequest)
  4. {// code for IE7+, Firefox, Chrome, Opera, Safari
  5. xmlhttp=new XMLHttpRequest();
  6. }else{// code for IE6, IE5
  7. xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  8. }
  9.  
  10. xmlhttp.onreadystatechange=function()
  11. {
  12. if (xmlhttp.readyState==4 && xmlhttp.status==200)
  13. {
  14. document.getElementById('files').style.display = "inline";
  15. document.getElementById('project').style.display = "none";
  16. pid = xmlhttp.responseText;
  17. }
  18. }
  19. var title=encodeURIComponent(document.getElementById("p_title").value);
  20. var description=encodeURIComponent(document.getElementById("p_description").value);
  21. var featured=encodeURIComponent(document.getElementById("p_featured").value);
  22. var parameters= "title="+title+"&description="+description+"&featured="+featured;
  23. xmlhttp.open("POST", "../scr/addProject.php", true);
  24. xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  25. xmlhttp.send(parameters);
  26. }

Report this snippet  

You need to login to post a comment.