2

I want IE8 to work with the following piece of jquery that returns ajax request as json:

$.ajax({
        url: formAction,
        type: 'post',
        dataType: 'json',
        data: form,
        success: function(data) {
            closeBlocker();
            if (data.count != 0) {
                $('#divid').toggle('slow');
            } else {
                $("#anotherdiv").css('display', 'none');
            }
            processSearchResult(target, data);
            reloadMap(data);
        }
});

In all other browsers, this triggers a call to fetch data. In IE8, however, this results in a dialog box popping up that asks users if they want to download a file. It looks like this:

enter image description here

I saw this post but havent been able to properly change the ContentType.

How can I do the same thing in IE8 without affecting other browsers? Thanks for your ideas!

Community
  • 1
  • 1
Dude
  • 193
  • 1
  • 2
  • 9

2 Answers2

1

I guess it's related to MIME type.

You have to tell browser to treat it as text/html. Then it will not try to download it, and will display it as text instead.

For this you can send Content-type = "text/html" in header.

Chankey Pathak
  • 21,187
  • 12
  • 85
  • 133
0

Probably this will solve your issue

IE8 treats json response as file and tries to download it

I had the same problem when I try to do ajax calls from other domain, I introduced proxy with my URL and it got fixed.

Hope it helps.

Community
  • 1
  • 1
Dilip Rajkumar
  • 7,006
  • 6
  • 60
  • 76