aishazafar
aishazafar

Reputation: 1120

Ajax call issue in jQuery

I am using the following code to receive some data from server. It always returns 200 ok with required data against my request. But it does not fire success or error event. If anybody can help me in that I'll be grateful to you.

$('body').on('click','a.btn_details',function(e){
            e.preventDefault();
            var _id = $(this).attr('id');
            var _data = {'action': 'product_details','product_id':_id};
            $.ajax({
                method: 'POST',
                url: '../common/products.php',
                dataType: 'json',
                data: _data,
                succes: function (resp) {
                    alert(resp.name);
                    return false;
                },
                error: function(resp){
                    alert("xd,vj,dfjbj");
                }
            });
            $('#prd_list_cont').hide();
            $('#prd_det_cont').show();
        });

Thanks in advance,

Aisha Zafar

Upvotes: 0

Views: 587

Answers (2)

Pankaj yadav
Pankaj yadav

Reputation: 1

Can you correct it and try as success with double s

    $('body').on('click','a.btn_details',function(e){
                e.preventDefault();
                var _id = $(this).attr('id');
                var _data = {'action': 'product_details','product_id':_id};
                $.ajax({
                    method: 'POST',
                    url: '../common/products.php',
                    dataType: 'json',
                    data: _data,
                    success: function (resp) {
                        alert(resp.name);
                        return false;
                    },
                    error: function(resp){
                        alert("xd,vj,dfjbj");
                    }
                });
                $('#prd_list_cont').hide();
                $('#prd_det_cont').show();
            }

);

Upvotes: 0

Gangai Johann
Gangai Johann

Reputation: 888

You have an error in your Ajax request. You need to replace succes with success :

success: function (resp) {
    alert(resp.name);
    return false;
},

Good luck

Upvotes: 2

Related Questions