converting curl to ajax call
I have a curl call like this
curl -X GET \
-H "X-Parse-Application-Id: **************" \
-H "X-Parse-REST-API-Key: ************" \
-G \
--data-urlencode 'username=cooldude6' \
--data-urlencode 'password=p_n7!-e8' \
https://api.parse.com/1/login
I want this to make an ajax call. I know how to add the headers but what i
don't know is what to do with the "urlencode" arguments.
This is the method that i wrote to take care of the headers
function getResponse(type, url, data, responseHandler) {
var result = $.ajax(
{
url: url,
data: data,
processData: false,
type: type,
contentType: 'application/json',
async: false,
beforeSend: setHeader
});
function setHeader(xhr) {
xhr.setRequestHeader('X-Parse-Application-Id','**************');
xhr.setRequestHeader('X-Parse-REST-API-Key', '**************');
}
return result;
}
No comments:
Post a Comment