I wish I had an answer for you, but unfortunately I'm just trying to figure out how to interact with the SW API using JavaScript myself.
Quick question, maybe you know the answer: If I have to include username and password info in my ajax request, would I put it in the data field?
data{
"username":"Bob",
"password":"mypassword"
},
Like that?