Programmatic(JavaScript) login into ODK Aggregate

Hi,

I am working on a web app that can use the Briefcase Aggregate API to sync
data from the aggregate server. But I am stuck as the basic authentication
is not working and I get "access denied" response even when using the right
username and password. Please help.

If someone has done this successfully, could you please share how.

Thanks,
GAURAV

··· ---------------------------------------------------------------------------------

Login function I am using:

$.ajax({
type: "GET",
url: ODKSubmissionURL,
async: false,
dataType: "xml",
contentType: "application/xml",
crossDomain: true,
headers: {
"Authorization": "Basic " + btoa(userID + ":" + password)
},
success: function (xmlData) {

        console.log(xmlData); 

        $('#getFormAlertDiv').hide(); 
        $('#waitAlertDiv').show(); 

    }, 
    error: function (request, textStatus, errorThrown) { 
        console.log(request.responseText); 
        console.log(textStatus); 
        console.log(errorThrown); 
    } 

});