Using JQuery, how would I call a JSONP API that required basic authentication?
Can I programatically handle this, or does the user have to interact and enter the username and password into the logon dialog?
JSONP allows you to sidestep the same-origin policy and to some extent make cross-domain Ajax calls. It's not a silver bullet, and it certainly has its issues, but in some cases it can prove invaluable when fetching data from a different origin.
JSONP stands for JSON with Padding. Requesting a file from another domain can cause problems, due to cross-domain policy. Requesting an external script from another domain does not have this problem. JSONP uses this advantage, and request files using the script tag instead of the XMLHttpRequest object.
dataType: jsonp for cross-domain request, that means request to different domain and dataType: json for same domain-same origin request. Loads in a JSON block using JSONP. Adds an extra "? callback=?" to the end of your URL to specify the callback.
The JSONP request does not use the XMLHttpRequest Object / System. Hence there is no way to do this directly.
I tried several times the approach mentioned in FinnNk's answer, but finally gave up after reading this discussion on the JQuery mailing list.
Update
When I said "no way to do this directly", what I meant is:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With