JSFiddle - React, Tailwind, and code Playground
by Regisc
HTML
<ul id="ajaxResponsePlatforms"></ul>
JavaScript
$.ajax({
type: "POST",
url: "/echo/json/",
data: {
json: '{"success":true,"PlatformInfo":[{"name":"PC"},{"name":"Servers"}]}'
},
dataType: "json",
//if received a response from the server
success: function(data, textStatus, jqXHR) {
//our platform was correct so we have some information to display
console.dir(data);
if (data.success) {
$("#ajaxResponsePlatforms").html("");
$.each(data.PlatformInfo, function(i, e) {
$("#ajaxResponsePlatforms").append("<li>value: " + e.name + "</li>");
});
}
//display error message
else {
$("#ajaxResponsePlatforms").html("<div><b>Country code is Invalid!</b></div>");
}
}
});