Site icon Shaharia's Blog

Super easy concepts about Ajax with jQuery. Really fantastic

 

Really jQuery had made ajax more easy to use and understand. jQuery framework has made also easier for Ajax operation. I have copied and pasted some code. Please have a look on the following coding you will get the complete concept of Ajax. Enjoy!!!

 

================

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Untitled Document</title>
<script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/
libs/jquery/1.3.0/jquery.min.js”></script>
<script type=”text/javascript”>
$(document).ready(function()
{
$(“#text”).keypress(function()
{
var x=document.getElementById(“text”).value;
$.ajax({
url: “data.php”,
global: false,
type: “POST”,

data: “arg=”+x,
dataType: “html”,
async:true,
success: function(msg){
// $(“$Result”).fade(300);
//alert(msg);
//document.getElementById(“Result”).innerHTML=msg;
$(“#Result”).html(msg).animate({opacity:0.25});

}
}
).responseText;

//)
})
}
)
</script>
</head>

<body>
<p>This is sample text<br />
This is a sample
</p>
<input id=”text”/>
<div id=”Result”>
</div>
</body>
</html>