JSFiddle - React, Tailwind, and code Playground

by Rob Janssen

HTML

<input type="button" value="No CORS" id="nocors"/>
<input type="button" value="CORS" id="cors"/>
<input type="button" value="CORS (Wrong domain)" id="corswd"/>
<p>Result: <span id="result">?</span></p>

JavaScript

function Test(cors) {
    $.ajax("http://got.devcorner.nl/testcases/1623779/?cors="+cors)
        .done(function (result) {
             $('#result').text(result.Response);
        }).fail(function() {
             $('#result').text('Request failed');
        });
}

$('#nocors').click(function() { Test('false'); });
$('#cors').click(function() { Test('true'); });
$('#corswd').click(function() { Test('wrongdomain'); });