Created
August 4, 2019 20:54
-
-
Save pawelztef/ce462f2324657f3e2d0298e9d6b8a7a3 to your computer and use it in GitHub Desktop.
Rails 5 ajax
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
fetch("/admin/media/" + mediaId + "/update_image", { | |
method: 'post', | |
body: JSON.stringify(myData), | |
headers: { | |
'Content-Type': 'application/json', | |
'X-CSRF-Token': Rails.csrfToken() | |
}, | |
credentials: 'same-origin' | |
}).then(function(response) { | |
return response.json(); | |
}).then(function(data) { | |
console.log(data); | |
}); | |
Rails.ajax({ | |
url: "/admin/media", | |
type: "get" | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment