title: Convert curl command to JavaScript
body: <p>I'm trying to convert this curl command to JavaScript:</p>
  <pre class="lang-bash prettyprint-override"><code>curl https://www.google.com/accounts/ClientLogin \
    --data-urlencode Email=mail@example.com \
    --data-urlencode Passwd=******* \
    -d accountType=GOOGLE \
    -d source=Google-cURL-Example \
    -d service=lh2
  </code></pre>
  <p>I want convert this command to an <code>$.ajax()</code> function. My problem is that I don't know what I have to put in the <code>setHeader</code> function below for the options present in command curl.</p>
  <pre class="lang-js prettyprint-override"><code>$.ajax({
      url: &quot;https://www.google.com/accounts/ClientLogin&quot;,
      type: &quot;GET&quot;,
  
      success: function(data) { alert('hello!' + data); },
      error: function(html) { alert(html); },
      beforeSend: setHeader
  });
  
  
  function setHeader(xhr) {
      // ?
  }
  </code></pre>