Skip to content

Instantly share code, notes, and snippets.

@pawelztef
Created August 4, 2019 20:54
Show Gist options
  • Save pawelztef/ce462f2324657f3e2d0298e9d6b8a7a3 to your computer and use it in GitHub Desktop.
Save pawelztef/ce462f2324657f3e2d0298e9d6b8a7a3 to your computer and use it in GitHub Desktop.
Rails 5 ajax
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