Can't make a POST request in AJAX?

  • 0
    someone can clearly show an example of sending a post request, it just does not work for me or I write it incorrectly.

    here is my code:

    const buttonGetInfo = document.querySelector('[type="button"]');
    
        buttonGetInfo.addEventListener('mouseup', function () {
            const xhr = new XMLHttpRequest();
    
            const responseType = 'text';
    
            xhr.open('POST', 'xmlData.html', true);
    
            xhr.onreadystatechange = function () {
                if (xhr.readyState == 4 && xhr.status == 200) {
                    document.write(`${xhr.response} <br>`);
                    document.write(xhr.responseText);
                }
            }
    
           xhr.send('string');
        })
    
    };
    JavaScript Anonymous, Jan 22, 2019

  • 0 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!