jquery - $.ajax using JsonResult - Returns "toJSON - function (key) { return this.valueOf(); }" -


here have:

controller

  [httppost]   public actionresult getnumbers(int id)   {       list<int> privids = new list<int>();       //my numbers!                       privids.add(2);       privids.add(3);       return json(privids);   } 

javascript

    var id = 1;     url = "/home/getnumbers/";     var getdata = {         'id': id     };     $.ajax({         type: "post",         url: url,         data: getdata,         datatype: "json",         success: function (result) {             $.each(result, function () {                 $.each(this, function (index, data) {                     alert(index + " - " + data);                 });             });         },         error: function (request, status, error) {             alert("fail");         }     }); 

the result

two alert boxes both containing:

tojson - function (key) { return this.valueof(); } 

the question

where numbers? (2 & 3 in example...)

edit

i swear did before. after..

                    success: function (result) {                         $.each(result, function (index, value) {                             alert(index + ': ' + value);                         });                     }, 

remove code , try , testing , if works write loop statement

success: function (result) {             // loop through             result.privids[0]         }, 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -