JavaScript Translate curl to Javascript ajax code translate curl to javascript

How can I translate this curl script to an AJAX request in JavaScript?

curl -X POST
     -d "grant_type=password&username=admin&password=Demo1234"
     -u "<ClientID>:<ClientSecret> " http://<host>/url/to/auth
Answer:1

I will show an example in pure JavaScript

function sendData()
{
    var formData = new FormData(); //create formData object to send data
        formData.append("grant_type, "password"); //via append you add data 
        formData.append("username", "admin"); 
        formData.append("password", "Demo1234");
    var xmlHttp = new XMLHttpRequest(); //create "ajax/xhr" object
        xmlHttp.onreadystatechange = function() //monitor status of response
        {
            if(xmlHttp.readyState === 4 && xmlHttp.status === 200) //if it's ok
            {
                console.log(xmlHttp.responseText); //then output data
            }
        }
        xmlHttp.open("POST", "http://<host>/url/to/auth"); 
        xmlHttp.setRequestHeader("Authorization", "Basic " + btoa("<ClientID>" + ":" + "<ClientSecret>");
        xmlHttp.send(formData);

}
Answer:2

I'm a bit confused after reading about how to use bitmasks to store boolean values. I would like to have a set of boolean values and then generate a unique integer for each combination of the values. ...

I'm a bit confused after reading about how to use bitmasks to store boolean values. I would like to have a set of boolean values and then generate a unique integer for each combination of the values. ...

I am not able to show two bar charts in one page. I have tried both ways, implementing these in two different <script> sections in and in one <script> section also. If one is shown if I ...

I am not able to show two bar charts in one page. I have tried both ways, implementing these in two different <script> sections in and in one <script> section also. If one is shown if I ...

  1. google charts work offline
  2. google charts not working
  3. google charts not working in ie11
  4. google charts not working in safari
  5. google charts stopped working
  6. google charts not working in chrome
  7. google charts not working in firefox
  8. google charts not working in internet explorer
  9. google charts not working in ie
  10. google charts not working in edge
  11. does google charts work offline
  12. google.charts.setonloadcallback not working
  13. google charts animation not working
  14. google.charts.load not working
  15. google charts colors not working
  16. google charts chartarea not working
  17. google charts options not working
  18. google charts ticks not working
  19. google charts isstacked not working
  20. google charts interpolatenulls not working

Why is the text of the paragraph always one letter behind? Shouldn't it automatically "copy" the value of the input to the paragraph and always be the same text? How can I fix this problem? $(...

Why is the text of the paragraph always one letter behind? Shouldn't it automatically "copy" the value of the input to the paragraph and always be the same text? How can I fix this problem? $(...

  1. input equal output
  2. input equal output energy
  3. should input equal output
  4. does work input equal output
  5. why does input equal output

When i click on a element with a class named sections, i should get an alert showing what is it's class index, but it's showing a wrong number. For example, if i click the first div element with a ...

When i click on a element with a class named sections, i should get an alert showing what is it's class index, but it's showing a wrong number. For example, if i click the first div element with a ...

  1. jquery indexof
  2. jquery indexof array
  3. jquery indexof is not a function
  4. jquery indexof case insensitive
  5. jquery index not working
  6. jquery indexof not working
  7. jquery index method
  8. jquery indexof multiple values
  9. jquery index returns negative
  10. jquery index of selected option
  11. jquery index of clicked element
  12. jquery indexeddb
  13. jquery index of class
  14. jquery indexof array of objects
  15. jquery index of parent
  16. jquery index greater than
  17. jquery index each
  18. jquery indexof return value
  19. jquery indexeddb plugin
  20. jquery index start at 1