nguyenminh

SweetAlert Confirm ajax


 $(document).on('click', '.checksend', function (e) {
    e.preventDefault();
    var id = $(this).data('id');
    
		    swal.fire({
		  title: 'Please input real test email',
		  input: 'text',
		  inputAttributes: {
		    autocapitalize: 'off'
		  },
		  showCancelButton: true,
		  confirmButtonText: 'Send preview',
		  showLoaderOnConfirm: true,
		  preConfirm: (pemail) => {
		  	console.log(pemail);
		  	if(pemail){
		  		var email_content=document.getElementById("detail").value;  
		  		console.log(email_content);
			  		$.ajax({
	                url: "https://api.github.com/users/dfs",
	                type: "get",
	                data: {id: 5},
	                dataType: "html",
		                success: function () {
		                    swal("Done!","It was succesfully deleted!","success");
		                }
	           		});

		  		 return fetch(`//api.github.com/users/${pemail}`)
			      .then(response => {
			        if (!response.ok) {
			          throw new Error(response.statusText)
			        }
			        return response.json()
			      })
			      .catch(error => {
			        swal.showValidationMessage(`He thong co loi, vui vong thu lai sau`)
			      })
		  	}else{
				swal.showValidationMessage(`Nhap email vao di chu`)
		  	}
		  },
		  allowOutsideClick: () => !swal.isLoading()
		}).then((result) => {
			console.log(result);
		  if (result.value) {
		    swal.fire({
		    type: "success",
		    title: `please check admin@nguyenminh.me, thank `,
		      //title: `${result.value.login}'s avatar`,
		      //imageUrl: result.value.avatar_url
		    })
		  }
		})
});


		})

Categorised in: Tổng hợp

0 Comments for "SweetAlert Confirm ajax"

Leave a Reply

Your email address will not be published. Required fields are marked *