Skip to content

Commit

Permalink
ajax
Browse files Browse the repository at this point in the history
  • Loading branch information
Agniprastha authored Oct 19, 2018
1 parent bef0a3b commit e8af320
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
38 changes: 38 additions & 0 deletions Ajax_add_2_no.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<html>
<head>
<script type="text/javascript">



function Addition()
{
var ob=false;
ob=new XMLHttpRequest();

var no1=document.getElementById("no1").value;
var no2=document.getElementById("no2").value;

ob.open("GET","ajax_add.php?num1="+no1+"&num2="+no2);
ob.send();

ob.onreadystatechange=function()
{
if(ob.readyState==4 && ob.status==200)
document.getElementById("add").innerHTML=ob.responseText; }
}

</script>
</head>

<body>

Enter first no :<input type=text name=no1 id="no1"><br>
Enter second no :<input type=text name=no2 id="no2"><br>
<input type=button name=submit value=add onClick="Addition()"><br>
<span id="add"></span>

<body>
</html>



11 changes: 11 additions & 0 deletions ajax_add.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
$n1=$_GET['num1'];
$n2=$_GET['num2'];

if((!empty($n1)) && (!empty($n2)))
{
$add=$n1+$n2;
echo "Addition = ".$add;
}
else "enter both nos";
?>

0 comments on commit e8af320

Please sign in to comment.