Skip to main content

Posts

Showing posts from November, 2017

Ajax onclick event example

(1)write code for  ajaxform.html : <html> <head> <script> function ajax_post() {     // Create our XMLHttpRequest object     var hr = new XMLHttpRequest();         // Create some variables we need to send to our PHP file         var url = "insert.php";         var id = document.getElementById("id").value;         var nm = document.getElementById("name").value;                       var vars = "id="+id+"&name="+nm;         hr.open("POST", url, true);     // Set content type header information for sending url encoded variables in the request     hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");     // Access the onreadystatechange event for the XMLHttpRequest object     hr.onreadystatechange = function() {           if(hr.readyState == 4 && hr.status == 200) {                       var return_data = hr.responseText;      

Ajax onmouseover and onmouseout event example

use following code  to try: <html> <body> <script> function loadimg1() { var xhttp=new XMLHttpRequest(); xhttp.onreadystatechange=function() { if(xhttp.readyState==4 && xhttp.status==200) { document.getElementById("targetDiv").innerHTML=xhttp.responseText; } }; xhttp.open("GET","Sandwiches.txt/sandwiches.txt",true); xhttp.send(); } function loadimg2() { var xhttp=new XMLHttpRequest(); xhttp.onreadystatechange=function() { if(xhttp.readyState==4 && xhttp.status==200) { document.getElementById("targetDiv").innerHTML=xhttp.responseText; } }; xhttp.open("GET","Pizzas.txt/pizzas.txt",true); xhttp.send(); } function loadimg3() { var xhttp=new XMLHttpRequest(); xhttp.onreadystatechange=function() { if(xhttp.readyState==4 && xhttp.status==200) {    document.getElementById("targetDiv").innerHTML=xhttp.responseText; } }; xhttp.open("