Last active
December 29, 2015 09:28
-
-
Save iWader/7650167 to your computer and use it in GitHub Desktop.
Sending ajax with dynamic key name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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