Given you are opening up an endpoint for username and password you should read about some of the threats described here under 4.4.3. Resource Owner Password Credentials (an OAuth2 flow that uses username and password) - the advise is still very important to follow even if this is not an OAuth solution, this covers the basics such as use SSL for transport level security but it also lists lots of other threats and countermeasures...
Using the credentials of a user inside JavaScript is a threat in itself. The OAuth 2 specification describes the implicit grant flow as the preferred approach to obtain a session (access_token) with JavaScript, the implicit flow aims to keep the credentials away from the javascript. There is an example walk-through of that approach here; however, this would involve you installing an authorisation server, using a 3rd party provider or implementing your own using something like DotNetOpenAuth (which isn't too difficult some good scenarios here).
But assuming you have ruled out OAuth 2 and the implicit grant flow etc, then...
I have placed an example online here which uses Basic auth via AJAX to return a Json Web Token JWT session token for use on all subsequent requests.
My example is basic therefore the token is stored in memory; however, cookies, local storage etc could be used to store the token for longer periods in a web environment.
My example uses the IdentityModel package from Thinktecture.
There are other examples and detailed walkthroughs below, and these should most certainly be used as further reference and guidance...
My example borrows from the above and from this question How to use Basic Auth with jQuery and AJAX?
If your login form and API are on different domains then you will also need to investigate CORS or JSONP, be sure to use a session signing key at the server that is stored safely and hidden on the server. The key is currently hardcoded in WebApiConfig.cs also be sure to reenable the must be over SSL option.
Once it is PhoneGap
Your server will likely be the same but you may be able to use the PhoneGap framework to replace some of your JavaScript...