简体   繁体   中英

This is my ajax call but in this success function not working

I am using a ajax call in my code. But in this ajax call the success function not working.

Below is the code I am using:

var data1 = { "name": namedata[0], "email": namedata[1], "mobile": namedata[2], "company": namedata[3], "message": namedata[4], };

$.ajax({
    type: "POST",
    url: url,
    data: data1,
    success: function (data) {
        alert("success");
        $('#myModalSuccess').css('display', 'block');

        $('.close').click(function () {
            $('#myModalSuccess').css('display', 'none');
        });

    },
    error: function () {
        $('#myModalFail').css('display', 'block');

        $('.close').click(function () {
            $('#myModalFail').css('display', 'none');
        });
    }
});

In error callback print the error in console.log() like below so that you will be able to identify the exact error-

$.ajax({
type: "POST",
url: url,
data: data1,
success: function (data) {
    alert("success");
    $('#myModalSuccess').css('display', 'block');

    $('.close').click(function () {
        $('#myModalSuccess').css('display', 'none');
    });

},
error: function (err) {
console.log(err)

    $('#myModalFail').css('display', 'block');

    $('.close').click(function () {
        $('#myModalFail').css('display', 'none');
    });
}});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM