Skip to content

Instantly share code, notes, and snippets.

@joshuaadrian
Last active December 26, 2015 19:09
Show Gist options
  • Save joshuaadrian/7199226 to your computer and use it in GitHub Desktop.
Save joshuaadrian/7199226 to your computer and use it in GitHub Desktop.
$('.parentElement').on('click', '.dynamicChildElement', function() {
$.ajax('/relative_file_path.php', {
type: "POST", // Defaults to get
data: {
'key' : 'value',
'key' : 'value'
},
dataType: 'json', // If retrieving JSON
contentType: 'application/json', // If retrieving JSON
success: function(response) {
// Success code here
},
error: function(request, errorType, errorMessage) {
// Error code here
},
timeout: 3000, // Defaults to browser default, so best to set explicitly set it
beforeSend: function() {
// Good place to place loading gif / animation
},
complete: function() {
// Fires after success or error
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment