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

Here is what I have:

  public ActionResult GetNumbers(int id)
      List<int> privIDs = new List<int>();
      //My Numbers!                
      return Json(privIDs);
    var id = 1;
    url = "/Home/GetNumbers/";
    var getData = {
        'Id': id
        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) {
The Result

Two alert boxes both containing:

toJSON - function (key) { return this.valueOf(); }
The Question

Where are my numbers? (2 & 3 in this example...)


I swear I did this before. But this is what i was after..

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


remove your code and just try this , just for testing , if it works just write a loop statement

success: function (result) {
            // loop through this

Need Your Help

Length of h:outputLabel changes after RichFaces AJAX call

jsf richfaces ajax4jsf

I have been trying to incorporate RichFaces into one of our more complicated pages to make it run a bit more smoothly via AJAX. Everything is working fine and it has solved a few problems I was hav...

Pagefile-backed memory-mapped files vs. Heap — what's the difference?

c++ c winapi heap memory-mapped-files

What is the advantage of using a memory-mapped file backed by the system paging file (through CreateFileMapping(INVALID_HANDLE_VALUE, ...), instead of just allocating memory from the heap the usual...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.