JSFiddle - React, Tailwind, and code Playground

by HYEONGJINKIM

HTML

<button id='button'>click</button>
<div></div>

JavaScript

var emart = emart || {};
emart.Model = emart.Model || {};
emart.View = emart.View || {};
emart.Presenter = emart.Presenter || {};

//CommonAjaxSetup
emart.Model.Common = new function(){
    var _init = function(){        
        $.support.cors = true;

		$(document).ajaxStart(function () {
			console.log("ajaxStart");
		}).ajaxStop(function () {
			console.log("ajaxStop");
		});

        $.ajaxSetup({
			//type : 'post',
			//crossDomain : true,
			//dataType : 'json',
			timeout : 5000,
            success : function(){
                alert("success");
            },
			error : function (xhr, textStatus, errorThrown) {				
				var sMsg = _getErrorMsg(xhr, textStatus, errorThrown);
			}
		});
    };
    
    var _getErrorMsg = function (xhr, textStatus, errorThrown) {
		var sErrorMsg = "";

		if (textStatus === 'timeout') {
			sErrorMsg = "Request Time out. Try again!";
		} else if (xhr.status === 0) {
			sErrorMsg = "You are offline! Please Check Your Network.";
		} else if (xhr.status === 404) {
			sErrorMsg = "Requested URL not found.";
		} else if (xhr.status === 500) {
			sErrorMsg = "Internel Server Error.";
		} else if (errorThrown === 'parsererror') {
			sErrorMsg = "Error. Parsing JSON Request failed.";
		} else if (errorThrown === 'timeout') {
			sErrorMsg = "Request Time out.";
		} else {
			sErrorMsg = "Unknown Error.";
		}

		return sErrorMsg;
	}
    
    _init();    
}();

emart.Model.User = new function () {
    var serviceBase = 'http://jsfiddle.net/echo/jsonp/',
        getAccount = function(acctNumber) {
            return $.getJSON(serviceBase + 'account', 
            { acctNumber: acctNumber });
        },
 
        getInfo = function(data) {            
            var htData = data || {
                text: 'some text',
                par1: 'another text'
            };
            
            return $.ajax({
                type: "get",
                url: serviceBase,
                data: htData,                
               ...