Skip to main content

EMAIL CHECKING USING AJAX




$.ajax({
    /* the route pointing to the post function */
    url: '/api/mail-check',
    type: 'POST',
    /* send the csrf-token and the input to the controller */
    data: {_token: CSRF_TOKEN, 'test' : 'tesst - data'},
    dataType: 'JSON',
    /* remind that 'data' is the response of the AjaxController */
    success: function (data, res) {
        console.log(data)
    }
});


var CSRF_TOKEN = $('meta[name="csrf-token"]').attr("content");
            $.ajax({
                /* the route pointing to the post function */
                url: "/api/mail-check",
                type: "POST",
                /* send the csrf-token and the input to the controller */
                data: {
                    _token: CSRF_TOKEN,
                    email: $("#form_email").val()
                },
                dataType: "JSON",
                /* remind that 'data' is the response of the AjaxController */
                success: function(data) {
                    if (data == true) {
                        $("#emailexistsid").show();
                        return true;
                    } else {
                        return false;
                    }
                },
                error: function(data) {
                    $("#emailexistsid").hide();
                }
            });

Comments

Popular posts from this blog