title: Adding variables into an ajax header parameter
body: <p>So this seemed like a simple task but spent already over an hour on this. I just want to pass a variable into the ajax header parameter. For some reason this is causing alot of problems. Im getting 500 errors returning from our server but if I type in the variable manually everything magically works. Not quite sure if theres a basic rule im not understanding but something isn't right. Anyone have any idea?</p>
  
  <p>Below is my code and the viariable I need to pass is the <code>headertype</code>.</p>
  
  <pre><code>saveIncident: function () {
      if (!confirm('Save?')) return
  
      var requestType = '' != '' ? 'PUT' : 'POST';
      var POST_Headers = '{"Accept": "application/json;odata=verbose"}';
      var PUT_Headers =  '{"Accept" : "application/json;odata=verbose","X-HTTP-Method':'MERGE","If-Match": item.__metadata.etag}';
      var headertype = (requestType != 'POST') ? POST_Headers : PUT_Headers;
  
      $.ajax({
          url: this.createIncidentUrl(requestType),
          type: requestType,
          processData: false,
          contentType: "application/json;odata=verbose",
          headers: headertype,
          data: JSON.stringify(IncidentManager.collectFieldValues()),
          success: function (data) {
          if (requestType == 'POST')
              console.log(data.d);   
              }
          });
  },
  </code></pre>