Skip to content

Instantly share code, notes, and snippets.

@namkyu
Last active July 30, 2018 08:26
Show Gist options
  • Save namkyu/335f0cf6daed569aed897ff16733931d to your computer and use it in GitHub Desktop.
Save namkyu/335f0cf6daed569aed897ff16733931d to your computer and use it in GitHub Desktop.
jquery #javascript

ajax

function callAjax(requestUrl, method, callbackFunction, data) {
	$.ajax({
		url : requestUrl,
		type : method,
		data : data,
		dataType : "html",
		async : false,
		success : function (result, status, xhr) {				
			callbackFunction(result)
        },
        error : function(e) {
        	currentAlert('layer_alert', messageFunction['default'], "일시적으로 오류가 발생했습니다.");
		}
	});
}
	
// POST
var data = {
	"mode" : mode,
	"gameCode" : gameCode	
};
var url = '/test';
callAjax(url, "POST", function (result) {
	$(".srch-result").html(result);
}, data);


// GET
var url = '/test';
callAjax(url, "GET", function (result) {
	$(".srch-result").html(result);
});

이벤트

$(document).ready(function() {	
});

$(document).on("click", "#id", function(e){
});

json

var resultJson = $.parseJSON(result);

make param

var param = {};
param.chargeAmt = chargeAmg;
param.gameCode = gameCode;
var url = host + "?" + $.param(param)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment