I'm trying to convert this curl command to JavaScript:
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
I want convert this command to an $.ajax()
function. My problem is that I don't know what I have to put in the setHeader
function below for the options present in command curl.
$.ajax({
url: "https://www.google.com/accounts/ClientLogin",
type: "GET",
success: function(data) { alert('hello!' + data); },
error: function(html) { alert(html); },
beforeSend: setHeader
});
function setHeader(xhr) {
// ?
}