JSFiddle - React, Tailwind, and code Playground

by guest271314

JavaScript

var urls = [["/echo/json/","abc"]
            , ["/echo/json/",{"abc": (function() { setTimeout(function() {$("body").append("<div id=data>" + "object" + "</div>"); $("#data").hide(0).fadeIn(1200)},1200) }())}]];

var request = function(url, _data) {
$.ajax({
    dataType : "json",
    type: 'POST',
    url:  url,
    data: {json : JSON.stringify({"data":_data})},
    processData : true
  })
  .done(function(data, textStatus, xhr) {
    if (typeof data.data === "string") {
        $("body").append("<div>" + data.data + "</div>")
    } else { 
        console.log(typeof data.data
                    , data
                    , xhr.responseText
                    , xhr.responseJSON);
      // this is where i do nothing and let JS run
    }
  })
};


$.each(urls, function(k, v) {
  request(v[0], v[1])
})