Can we call the API via jQuery.ajax?

Created on 15 July 2014, about 11 years ago
Updated 28 July 2025, 5 days ago

Hi sorry if this has been covered elsewhere. If so, please point me in the right direction.

I'm using replicate to duplicate nodes from a view listing of specific documents and in doing so, I assign the user in focus as the author of the duplicate and put in a specific title, etc... jQuery.ajax will be the most intiutive method for our purpose but I'm not sure how I can access the API that way. Is this possible? If not, I'll make it so if I can get some direction.

My code is as follows:


  /*
   * Use jQuery.ajax to push values for:
   * 	$uid 
   *	$user_name
   *	$node_id 
   *	$organization_id
   */

  $entity = array_shift(entity_load('node', array($node_id)));

  $cloned_entity = replicate_clone_entity('node', $entity);

  $source_document_title = $cloned_entity->title;
  $target_title = $source_document_title . " - " . $user_name;

  $cloned_entity->title = $target_title;
  $cloned_entity->uid = $uid;
  $cloned_entity->revision_uid = $uid;
  $cloned_entity->organization = array ( 'und' => array ( 0  => array ('target_id' => $organization_id))); //Custom entity reference field

  if ($cloned_entity) {
    entity_save('node', $cloned_entity);
  }

💬 Support request
Status

Closed: outdated

Version

1.1

Component

Documentation

Created by

🇨🇦Canada awasson

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024