title: How can I make an HTTP DELETE request through JavaScript?
body: <p>I work in advertising. I am using the FB graph API to 'DELETE' ad assignments from the platform for a client using the HTTP DELETE method.</p>
  
  <p>My requests are in the format:</p>
  
  <pre><code>https://graph.facebook.com/v2.5/{{NODE_ID}}/{{EDGE_NAME}}?field_ids=['123456']
  </code></pre>
  
  <p>I normally use the graph explorer tool (<a href="https://developers.facebook.com/tools/explorer" rel="nofollow">https://developers.facebook.com/tools/explorer</a>) to accomplish such a task, but the client has provided over 8000 assignment to delete so doing it manually one by one would be tough.</p>
  
  <p>How can I invoke an HTTP DELETE method using JavaScript? I want to use a for loop like this:</p>
  
  <pre><code>var node_ids = ["123","456","789"];
  var field_ids = ["abc","def","ghi"];
  
  for (i = 0; i &lt; node_ids.length &lt; i++){
  
  // MAKE DELETE REQUEST to "https://graph.facebook.com/v2.5/" + node_ids[i] + "/{{EDGE_NAME}}/?field_ids=['" + field_ids[i] + "']";
  
  }
  </code></pre>
  
  <p>I saw a code like this online that I thought might be applicable, but I don't know how it works...</p>
  
  <pre><code>$.ajax({
      url: '/script.cgi',
      type: 'DELETE',
      success: function(result) {
          console.log(result)
      }
  });
  </code></pre>
  
  <p>It looks like jquery but I guess it must be ajax? Does ajax need a library to be referenced like jquery does? Is it as simple as putting this function inside my for-loop and passing the URL I'm building inside the for loop to the 'url' field in the ajax call...?</p>
  
  <p>What is the best function to pass to the 'success' parameter here so I know my request was successful? Is it possible to return the response from the delete request i.e. success:true if it works?</p>
  
  <p>The more explicit you can be, the better!</p>
  
  <p>Do you foresee any issues with me looping through 8000 entries across two arrays (one contains the node ID / object I am editing, and one contains a field related to the edge I'm accessing which will delete aka 'remove' the assignment from the node I am accessing...?</p>
  
  <p>Thanks!</p>