4

The script I am working on makes ajax call and it works fine on Firefox, chrome and IE8+. But on IE7, I am getting an out of memory error. The memory gets up to 120MB. I am using jQuery 1.8.3. The error also happens in jQuery 1.9 and 1.7.

the source:

$.ajax({
    type: "POST",
    contentType: "application/json; charset=utf-8",
    url: 'data.asmx/GetChildren',
    data: '{parent:"program","child":"office","id":' + this.Item_id + '}',
    dataType: 'json',
    success: function (r) {
        var data = r.d.data;
    }
});

this is the profile i get for IE7:

edit: updated with source edit: finally had time to go through the problem again. turned out to be a simple looping problem. not jQuery ajax's fault.

Funky Dude
  • 3,867
  • 2
  • 23
  • 33

6 Answers6

1

IF number of children are more, then the value returned to the var data will be more.

The maximum length of JSON strings. The default is 2097152 characters, which is equivalent to 4 MB of Unicode string data. source Microsoft

So size is not an issue, but the character if exceeds then it is a problem. :)

MarmiK
  • 5,639
  • 6
  • 40
  • 49
0

Don't know if it has something to do with your problem, but there are two things making your data an invalid JSON.

parent must be enclosed in quotation marks, just as the id value (you are only closing and reopening the string).

So, it should be like this:

$.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: 'data.asmx/GetChildren',
        data: '{"parent":"program","child":"office","id":"' + this.Item_id + '"}',
        dataType: 'json',
        success: function (r) {
            var data = r.d.data;
        }
});
Anderson Pimentel
  • 5,086
  • 2
  • 32
  • 54
0

This problem can occur if virtual memory has been disabled.
To enable virtual memory, follow these steps:

Click the Start button, point to Settings, and then click Control Panel. Double-click the System icon. On the Performance tab, click Virtual Memory. Click the "Let Windows manage my virtual memory settings (recommended)" option. Or, if you must use your own virtual memory settings, allow as much space as possible for the maximum size. Click OK.

Sanjeev Rai
  • 6,721
  • 4
  • 23
  • 33
  • 1
    i don't think this is it. this seems like a jQuery + IE 7 bug. I can't tell my users to enable virtual memory. – Funky Dude Mar 15 '13 at 16:32
0

As per jQuery docs you can pass plain object so I would suggest to use object instead. Also can you please try to use Id like this and see if it makes any difference.

var id = this.Item_id; //
$.ajax
({
    type: "POST",
    url: 'data.asmx/GetChildren',
    data: {"parent":"program","child":"office","id": id},
    dataType: 'json',
    success: function (r) 
    {
        //Please use console.log(r) and see what is coming back here
    }
});

or simply

var id = this.Item_id; //
$.post("data.asmx/GetChildren", 
{
    "parent":"program",
    "child":"office",
    "id": id
}, function(r)
{
    //console.log(r);
},"json");
nicholasnet
  • 2,117
  • 2
  • 24
  • 46
0

Have you try to send a JSON.stringify instead of an Object, and in the server side decode?

https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/JSON/stringify
ncubica
  • 8,169
  • 9
  • 54
  • 72
0
$.ajax({
    type: "POST",
    contentType: "application/json; charset=utf-8",
    url: 'data.asmx/GetChildren',
    data: '{parent:"program","child":"office","id":' + this.Item_id + '}',
    dataType: 'text',
    success: function (r) {
        var data = (eval("[" + r + "]")[0]).d.data;
    }
});
  • Changed dataType to "text".
  • Used eval("[" + textJson + "]")[0] to get the object data.
    • If it still fails replace the "var data = ..." line with "var data = r;" and report if that fails also.
Louis Ricci
  • 20,804
  • 5
  • 48
  • 62