Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6014289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:40:14+00:00 2026-05-23T02:40:14+00:00

I’m having a problem similar to jQuery $.ajax Not Working in IE8 but it

  • 0

I’m having a problem similar to jQuery $.ajax Not Working in IE8 but it works on FireFox & Chrome, but with a different use case.

I’m using the jQuery Form plug-in to handle a file upload to an ASP.NET MVC controller, which sends the file off for parsing and processing. If an Exception is thrown, it should alert the user to the issue.

//client side code
//make an ajax call, sending the contents of the file
                    $("#ajaxUploadForm").ajaxSubmit({
                        dataType: 'json',
                        url: '/plan/Something/ExcelImport',
                        iframe: true,
                        beforeSend: function () {
                            $(".ui-dialog-buttonpane").find("#my_progress").fadeIn();
                        },
                        success: function (data, textStatus) {
                            output = "<center><span class='flash'>" + data.message + "</span></center>";
                            $("#flash_message").html(output).fadeIn('slow');
                            setTimeout(function () { $("#flash_message").fadeOut() }, 5000);
                            cleanup();
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            alert("XMLHttpRequest is " + XMLHttpRequest);
                            var contents = "";
                            for (prop in XMLHttpRequest) {
                                contents += "\na property is " + prop + " it's value is " + XMLHttpRequest[prop];
                            }
                            alert("the contents are " + contents);
                            alert("textStatus is " + textStatus);
                            alert("errorThrown is " + errorThrown);
                            //comes back in an HTML envelope. This should be parsed with regex, but I can't get it to work. Dirty hack
                            response = XMLHttpRequest.responseText.substring(XMLHttpRequest.responseText.indexOf("<body>"));
                            response = response.replace("<body>", "");
                            response = response.replace("</body>", "");
                            alert("There was a problem with the upload.\r\n" + response);
                        },
                        complete: function (XMLHttpRequest, textStatus) {
                            $(".ui-dialog-buttonpane").find("#my_progress").remove();
                            something_import.dialog('close');
                            something_import.dialog('destroy');
                        }
                    });

//server side code
public FileUploadJsonResult ExcelImport()
    {
        FileUploadJsonResult result = new FileUploadJsonResult();
        HttpPostedFileBase hpf = Request.Files[0] as HttpPostedFileBase;
        if (hpf.ContentLength == 0)
            return new FileUploadJsonResult { Data = new { message = "File contained no data" } };
        String fileName = Path.GetFileName(hpf.FileName);
        String timeStampedFile = fileName.Insert(fileName.IndexOf('.'),"_"+DateTime.Now.ToFileTimeUtc());
        string savedFileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory + "tempo", timeStampedFile);
        hpf.SaveAs(savedFileName);
        try
        {
            result = ProcessFile(savedFileName, Request["Id"]) as FileUploadJsonResult;
        }
        catch (ArgumentException e)
        {
            this.Response.StatusCode = 500;
            this.Response.StatusDescription = System.Net.HttpStatusCode.BadRequest.ToString();
            Response.Write(e.Message);
            result = Json(new { message = e.Message, stackTrace = e.StackTrace }) as FileUploadJsonResult;  
        }
        return result;
    }

This works perfectly in Chrome and Firefox. In IE, the XMLHttpRequest object coming back is different:

FF:alt text

IE:
alt text

I’ve been Googling around for differences between the browser implementations of XMLHttpRequest, but haven’t found anything that deals specifically with this case. Stymied.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T02:40:14+00:00Added an answer on May 23, 2026 at 2:40 am

    The reason this is happening is because of the iframe fallback strategy that ajaxSubmit employs. I think since the response gets posted into the iframe IE tries to figure out how to dipslay it and decides that it wants to ask you to download the response instead of just putting it in the iframe.

    I came across this same situation a while ago and found an article (that I can’t find now) that offered a workaround.

    If you surround your json response in a textarea nobody is going to complain(IE,FF,Chrome,probably Safari) and you’ll get your response parsed correctly.

    E.g. if you are returning

    {Id: 1, Name: 'Me'}
    

    just return:

    <textarea>{Id: 1, Name: 'Me'}</textarea>
    

    You see now IE thinks it’s html so it inserts it into the hidden iframe. Your ajaxSubmit function still gets called and parses the json correctly and then everybody’s happy. 🙂

    If you’re using ASP.NET MVC you could shamelessly copy this extension method 🙂

    public static class ControllerExtensions
    {
        public static ActionResult JsonSafe(this IController controller, object obj)
        {
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            return new WriteResult(string.Format("<textarea>{0}</textarea>", serializer.Serialize(obj)));
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I've tracked down a weird MySQL problem to the two different ways I was
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.