Created
October 15, 2019 18:58
-
-
Save szTheory/0dcbae2af1d34c224fd4d13e545b509a to your computer and use it in GitHub Desktop.
Rails UJS parameters as string. For submitting POST or PUT forms with ajax for Turbolinks
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
Rails.ajax({ | |
type: 'GET', | |
url: '/users/' + <%= params[:id] %> + '/country', | |
// see: https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams | |
data: new URLSearchParams({'country': country}).toString(), | |
success: function (response) { | |
// ... | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment