Revision: 40463
Updated Code
at February 2, 2011 11:15 by dropthenerd
Updated Code
$('.link').click(function(){ var params = {'answer' : $(this).attr('answer')}; var href = $(this).attr('href'); $.post( url: href, data :params, success: function(data){ switch(data.success){ case 1: //success alert('Correct Response: ' + data.message); break; case 0: //failure alert('Incorrect Response: ' + data.message); break; default: //anything else - in this case, an error. alert('Error! ' + data.message); break; } }, dataType: 'json' ); return false; });
Revision: 40462
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at February 2, 2011 11:02 by dropthenerd
Initial Code
$('.link').click(function(){ var params = {'answer' : $(this).attr('answer')}; var href = $(this).attr('href'); $.post( href, params, function(data){ switch(data.success){ case 1: //success alert('Correct Response: ' + data.message); break; case 0: //failure alert('Incorrect Response: ' + data.message); break; default: //anything else - in this case, an error. alert('Error! ' + data.message); break; } }, 'json' ); return false; });
Initial URL
http://www.dropthenerd.com/ajax-a-simple-approach-that-you-will-use-and-reuse/
Initial Description
Initial Title
Simple Ajax Example
Initial Tags
ajax
Initial Language
jQuery