How to upload file using AJAX and PHP ?

Code – HTML <input type=”file” name=”myfile” id=”myfile”/> <input type=”button” value=”U[load” onClick=”up()”/> function up() { var file=document.getElementById(“myfile”).files[0]; var data=new FormData();data.append(“myfile”,file,file.name); var…

Continue Reading →

How to send data using POST method in AJAX ?

Code – HTML <html> <head> <title>AJAX – POST Method</title> function postdata() { var data=document.getElementById(“txt”).value; var xhr=new XMLHttpRequest(); xhr.open(“POST”,”a.php”,true); xhr.setRequestHeader(“Content-type”, “application/x-www-form-urlencoded”);…

Continue Reading →