This answer has helped me largely but hasn\'t fully resolved my issues. I\'m using code similar to that, which is:
function getResponse() {
var the_url = \"
If you were using simple AJAX, then you could just add custom (basic authentication) header at the begining of your AJAX call. But you are using JSONP, which actually is equivalent to adding tag to your HTML.
So what you are asking is: can I do basic authentication with tag? No, you can't.
The only possibility left for you is to do server side processing, like Matt Gibson suggested.
Note however, that the browser should fire authentication dialog after the JSONP request (also see this answer). Isn't it working in your case??