XMLHttpRequest用于连接到安全URL

时间:2015-12-17 03:49:29

标签: javascript authentication ssl xmlhttprequest

我正在使用我在此处找到的示例代码:
http://www.w3schools.com/ajax/tryit.asp?filename=tryajax_post2

我想从需要身份验证的端点获取JSON字符串。

  1. 如何通过向端点发出请求来指定我的ID / Pass(是否有可以使用的HTTP标头要求我进行身份验证)?

  2. 连接到可能需要我们进行身份验证的网址的解决方法是什么?

  3. 如何指定使用SSL证书获取响应?

  4. < script >
      function loadDoc() {
        var xhttp = new XMLHttpRequest();
        xhttp.onreadystatechange = function() {
          if (xhttp.readyState == 4 && xhttp.status == 200) {
            document.getElementById("demo").innerHTML = xhttp.responseText;
          }
        };
        xhttp.open("POST", "demo_post2.asp", true);
        xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xhttp.send("fname=Henry&lname=Ford");
      } < /script>

0 个答案:

没有答案