What does it mean if I put action: 0 in the data attribute when I use ajax?

0

I do not know if I formulate the question well hehe, I mean what does this piece of code mean?

 $.ajax({type: 'POST', url: _url,
            data: {action: 0, search_head: search_head, chngroup: chngroup, language: language},
            async: false, dataType: 'json', success: function(data) {
                var n = data.length;
                if (n === 0) {
                    $('<center></center>').appendTo('#css-interno-li-grid');
                    return false;
                }
                if (typeof specialGrid === "undefined") {
                    if (n === 1) {
                        Products.Form(data);
                    } else {
                        Products.Grid(data);
                    }
                } else {
                    if (n === 1) {
                        Products.SpecialGrid(data);
                    } else {
                        Products.SpecialGrid(data);
                    }
                }
            }
        });

I'm interested to know what it means where you put action: 0 means that this request is being sent to the same file or what? yes, this code is not mine and yes, I'm a novice with ajax hehe

    
asked by Yohanna 17.04.2017 в 18:00
source

1 answer

0

The option data in Ajax means that it is the data that you are going to send in your case action is the name of the variable that you are going to send and 0 is the value that you are sending in that variable.

Always send nombrevar : valorvar

    
answered by 17.04.2017 в 18:17