DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Stephen has posted 20 posts at DZone. View Full User Profile

Useful Javascript Code

01.28.2009
| 540 views |
  • submit to reddit
        Confirm Delete
<a href="delete.page?id=1" onclick="return confirm('Are you sure you want to delete?')">Delete</a> 

Convert links to Ajax
<html>
  <head>
	<script type="text/javascript" src="jquery-1.3.1.js"></script>
	<script type="text/javascript" src="jquery.form.js"></script>
	
	<script>
	    $(document).ready(function(){
		  $('a').bind('click',function(event){
			event.preventDefault();
		    $.get(this.href,{},function(response){ 
		 	   $('#response').html(response)
		    })	
		 })
		});
	</script>
  </head>
<body>

  <li><a href="response.html"/>Response</a>
	
	<div id="response"></div>
	
</body>