-
Notifications
You must be signed in to change notification settings - Fork 173
Saving an entity back to Drupal
jeff-h edited this page Oct 14, 2015
·
2 revisions
Following is some sample jQuery code which illustrates the simplest use case for saving entity data back to Drupal.
jQuery.ajax({
url: "http://mydrupalsite.com/api/v1.0/entity-endpoint-name",
type: "POST",
headers: {
"Content-Type": "application/json",
},
contentType: "application/json",
data: JSON.stringify({
"property_one": "5",
"property_two": "4",
"etc": "abc"
})
})
.done(function(data, textStatus, jqXHR) {
console.log("HTTP Request Succeeded: " + jqXHR.status);
console.log(data);
})
.fail(function(jqXHR, textStatus, errorThrown) {
console.log("HTTP Request Failed");
})
.always(function() {
/* ... */
});
The properties contained in the data
element correspond with those you defined in your custom Drupal module's publicFields()
function for this entity type.