SHARE
TWEET

Create a SIte visit

dav4530 Feb 20th, 2014 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     createSiteVisit: function() {
  2.       var d = $.Deferred();
  3.       var date = new Date("2014-02-19");
  4.       var mydate = date.toISOString();
  5.       var arr = [];
  6.      
  7.       // BEGIN: drupal services node create login (warning: don't use https if you don't have ssl setup)
  8.       $.ajax({
  9.           url: "http://192.168.38.114/dt11/?q=api/node.json",
  10.           type: 'post',
  11.           data:
  12.           'node[type]=ftritem
  13.           &node[title]=kenya
  14.           &node[name]=dave
  15.           &node[taxonomy_vocabulary_7][und][0][tid] = 211
  16.           &node[field_ftritem_date_visited][und][0][value]=2014-02-17T00:00:00+3
  17.           &node[field_ftritem_public_summary][und][0][value]=Summaries are invariably short
  18.           &node[field_ftritem_narrative][und][0][value]=Please provide a full report
  19.           &node[field_ftritem_field_trip][und][0][target_id]=13975
  20.           &node[field_ftritem_images][und][0]='+arr,
  21.           dataType: 'json',
  22.           error: function(XMLHttpRequest, textStatus, errorThrown) {
  23.             console.log('error '+errorThrown);
  24.             d.reject();
  25.           },
  26.           success: function (data) {
  27.             console.log('success');
  28.             d.resolve();
  29.           }
  30.       });
  31.       // END: drupal services node createNode
  32.  
  33.       return d;
  34.     }
RAW Paste Data
Want to get better at JavaScript?
Learn to code JavaScript in 2017
Top