//モーダル表示
$(function(){
    $('.js-modal-open').on('click',function(){
        $('.js-modal').fadeIn();
        return false;
    });
    $('.js-modal-close').on('click',function(){
        $('.js-modal').fadeOut();
        return false;
    });
});

//モーダルフォーム送信
$('#ok-btn').on('click', function(){
	let token = $("meta[name='_csrf']").attr("content");
    let header = $("meta[name='_csrf_header']").attr("content");
    $(document).ajaxSend(function(e, xhr, options) {
      xhr.setRequestHeader(header, token);
    });
    
    let data = {
			name: $('#name').val(),
			postalCode: $('#postal-code').val(),
			address: $('#address').val(),
			phoneNumber: $('#phone-number').val(),
			email: $('#email').val(),
			password: $('#password').val()
	};

    $.ajax({
      type: "POST",
      url: "/limited/signUp",
      contentType: 'application/json',
      dataType: "json",
      data: JSON.stringify(data)
    }).done(function(response, textStatus, jqXHR ) {
    	$('.js-modal').fadeOut();
    }).fail(function(jqXHR, textStatus, errorThrown) {
      //alert("Failed.");
  });
});

