본문으로 바로가기

php ajax 샘플

category [ Web 관련 ]/php 2021. 5. 28. 18:38
function dbassign_ok(call_idx) {
	if (confirm("DB를 분배 하시겠습니까?")) {

		$("#loding_img").show();

		var sendUrl = 'process/ajax_dbassign.php';
		var post_data = $("form[name=frm]").serialize() ;

		$.ajax({
			type: "POST",
			url: sendUrl,
			data: post_data,
			dataType: 'json',
			success: function(data) {
				//성공
				console.log(data);
				//alert(data.landing_key)
			},
			error: function(request, status, error) {
				//에러
				//alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error);
				alert('통신 오류');
			},
			complete: function() {
				$("#loding_img").hide();
			}
		});
	}
}

 

 

 

$rtn = array(
	'landing_key' => $landing_key,
	'counselor' => $counselor,
	'result' => 'error',
	'status' => false,
	'message' => '로그인이 필요합니다.'
);


header("HTTP/1.0 404 Not Found");
echo json_encode($rtn);