1

i've write this javascript code :

 var list=[];
            $.ajax({
                url: 'HandlerGetAutoCompleteList.ashx',
                data: {},
                dataType: "json",
                success: function (data) {
                    var a = data.data.length;
                    for (var b = 0 ; b < a; b++) {

                        var Info = {
                            value: data.data[b].ProductID,
                            label: data.data[b].Name
                        };

                        list.push(JSON.stringify(Info));
                        alert(list[b]);
                    }
                    alert(list);
                }
            });

here i load a list on product name and id, i use alert function to show the values returned, i have something like this :

"value":2,"label":"Soya Bean"

but when use the alert function outside $.ajax function to show the list content, it give me nothing. how to return it?

alim91
  • 538
  • 1
  • 8
  • 17

0 Answers0