Sunday, 11 June 2017

jquery ajax or axios , which one is faster?

im using ajax to make a live search with get method. and speed is very important to me.

and i want know Jquery $.Ajax is faster of Axios??

            $.ajax({
            url:"/ajax-search",
            type: "get",
            data:{search:txt2},
            dataType:"json",
            success:function (data)
            {
                $("#txtHint2").html('');
                for (i = 0; i < data.length; i++)
                {
                    $("#txtHint2").append(data[i].name);
                }
            },
            error:function (error) {
                alert(eval(error));
            }
        });

or

            axios.get('/ajax-search', {
            params: {
                search: txt
            }
        })
            .then(function (response) {
                $("#txtHint").html('');
                for (i = 0; i < response.data.length; i++)
                {
                    $("#txtHint").append(response.data[i].name);
                }
            })
            .catch(function (error) {
                console.log(error);
            });



via K1-Aria

No comments:

Post a Comment