Skip to content

Instantly share code, notes, and snippets.

@iWader

iWader/ajax_dyn_key

Last active Dec 29, 2015
Embed
What would you like to do?
Sending ajax with dynamic key name
$(document).ready(function() {
function ajax_save(field, value)
{
$.ajax({
type: 'POST',
url: '{{ URL::to('/test') }}',
data: field + '=' + value
}).done(function(data) {
console.log('Response: ' + data);
}).fail(function(data) {
console.log('Failed: ' + data);
});
}
$('#input_1').blur(function() {
ajax_save('input_1', $('#input_1').val());
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment