Skip to content

Instantly share code, notes, and snippets.

@saturngod
Created April 5, 2011 11:45
Show Gist options
  • Save saturngod/903453 to your computer and use it in GitHub Desktop.
Save saturngod/903453 to your computer and use it in GitHub Desktop.
jquery ajax
<html>
<head>
<title>Sample Ajax</title>
<script src="http://code.jquery.com/jquery-1.5.2.min.js" ></script>
<script>
$(document).ready(function(){
$("#ajaxtest").click(function(){
var data = [];
data.push("a");
data.push("b");
$.ajax({
type: "POST",
url: "test.php",
data: "mydata="+data,
success: function(data) {
alert(data);
}
});
return false;
});
});
</script>
</head>
<body>
<a href="#" id="ajaxtest">Ajax</a>
</body>
</html>
<?php
if(isset($_POST['mydata']))
{
echo "YES";
}
else
{
echo "NO";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment