This might be a little bit of a stretch, but let's just assume that we need it to work this way:
- I have an index.html file in the web root of a server. The javascript in that file needs to make an ajax request to /secure/ajax.php
- Everything in the /secure/ directory is protected using Basic Authentication
- I don't want to bother the user with logging in to the /secure/ section
Can I submit credentials for basic authentication wit开发者_高级运维h an AJAX request?
xmlHttpRequest.setRequestHeader is your friend.
xhr.setRequestHeader("Authentication", "username:password in base64")
you just need to convert username:password to base64
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论