« Previous Next »

Thread: Weird IE error with AJAX - parseerror - works on IIS 5.1

Last post 03-17-2009 3:16 AM by nitech. 8 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (9 items)

Sort Posts:

  • 03-04-2009, 1:27 PM

    • KasperFP
    • Not Ranked
    • Joined on 03-04-2009, 5:49 PM
    • Posts 8

    Weird IE error with AJAX - parseerror - works on IIS 5.1

    Dear all,

     

    I've been breaking my brain the last couple of days with this issue, and I've asked several JavaScript / AJAX experts, who all concludes the same as I have. The error must be a server issue.

    I have two files: ajax.html and ajax.asp.

    http://www.test.orango.nu/dev/ajax.html

    This is what happens / should happen:
    1. ajax.html posts to ajax.asp, with the query string cmd=a command value.
    2. ajax.asp response.writes the query string "cmd"
    3. ajax.html alert's the response text

     

    So what does actually happens? No one knows. In ALL other browsers than Internet Explorer (I use v7, haven't tried other versions), it alerts "a command value" (use the link I provided you to see for yourself) - but with Internet Explorer - it doesn't :( it returns an error.

     

    So why do I blame the server? because when I remove the "response.write request("cmd")" line from ajax.asp, so that ajax.asp does nothing, then the ajax.html alerts without anything in the alert pop-up.

    Do you have any idea what the frick could be the matter? If I download the two files to my localhost, it works after the intention..

     

    My ajax.asp file looks like this:
    <%
    Response.ContentType = "text/plain" 
    Response.AddHeader "Content-Type", "text/plain;charset=UTF-8" 
    Response.CodePage = 65001 
    Response.CharSet = "UTF-8"


    response.write request("cmd")
    %>
    and it's encoded in UTF-8 as well

    I've tried to change the content-type, the encoding, I've tried to use jQuery and other js-kits and so on and so on, but nothing seems to work with Internet Explorer, so I'm guessing it's an issue with my server, which by the way, is:
    Windows Web Server 2008 64 bit
    IIS 7.0 running 32-bit compatible mode

     

    All suggestions are welcome, I'm willing to try anything to make this work.

    Thanks in advance

  • 03-04-2009, 3:54 PM In reply to

    • anilr
    • Top 10 Contributor
    • Joined on 05-23-2006, 6:13 PM
    • Redmond, WA
    • Posts 2,343

    Re: Weird IE error with AJAX - parseerror - works on IIS 5.1

    Can you collect failed request trace on your IIS7 server?  Also, I noticed that you are using verb "post" instead of "POST" in your html page - not sure if that would cause that issue.

    Anil Ruia
    Senior Software Design Engineer
    IIS Core Server
  • 03-05-2009, 2:47 AM In reply to

    • KasperFP
    • Not Ranked
    • Joined on 03-04-2009, 5:49 PM
    • Posts 8

    Re: Weird IE error with AJAX - parseerror - works on IIS 5.1

     I've changed it to "POST" now, but with no luck as I expected.

     

    Can you tell me how to collect the failed request trace? I have full administrator rights, I'm just not sure how to do what you ask me. :-)

  • 03-06-2009, 7:14 AM In reply to

    • KasperFP
    • Not Ranked
    • Joined on 03-04-2009, 5:49 PM
    • Posts 8

    Re: Weird IE error with AJAX - parseerror - works on IIS 5.1

     So I followed this guide: http://www.trainsignaltraining.com/iis-7-troubleshooting/2008-07-09/

     

    And created a trace rule on "ASP (*.asp)" with "Status code(s): 100-999", and enabled it on my site, but so far it haven't saved any trace logs.. :-(

     

     

  • 03-13-2009, 7:05 AM In reply to

    • nitech
    • Not Ranked
    • Joined on 03-13-2009, 7:03 AM
    • Posts 5

    Re: Weird IE error with AJAX - parseerror - works on IIS 5.1

     Hi,

     I am experiencing the same problem on IIS7 on Windows 2008 Server. The same site is running fine on IIS6 on Windows 2003 Server. 

     I also use: 

    Response.ContentType = "text/html"
    Response.AddHeader "Content-Type", "text/html; Charset=UTF-8"
    Response.CodePage = 65001
    Response.CharSet = "UTF-8"         

     It looks as though IIS7 somehow delievers the character encoding to the client differently than IIS6

     Kind regards,

    nitech

  • 03-13-2009, 7:22 AM In reply to

    • nitech
    • Not Ranked
    • Joined on 03-13-2009, 7:03 AM
    • Posts 5

    Re: Weird IE error with AJAX - parseerror - works on IIS 5.1

    For those of you who can read Danish, there is a lengthy discussion here: http://www.eksperten.dk/spm/866288?a=rssreader&i=10

    They conclude that it works if you comment out the "AddHeader" line, like so: 

        Response.ContentType = "text/plain"
        'Response.AddHeader "Content-Type", "text/plain; Charset=UTF-8"
        Response.CodePage = 65001
        Response.CharSet = "UTF-8" 

    This however doesn't work on my server. 

  • 03-15-2009, 6:11 AM In reply to

    • KasperFP
    • Not Ranked
    • Joined on 03-04-2009, 5:49 PM
    • Posts 8

    Re: Weird IE error with AJAX - parseerror - works on IIS 5.1

     Yeah I know, it's me that started that discussion as well :-D

    Try to comment out the "Response.ContentType" as well, that made it work for me...

     

     

  • 03-16-2009, 4:01 AM In reply to

    • nitech
    • Not Ranked
    • Joined on 03-13-2009, 7:03 AM
    • Posts 5

    Re: Weird IE error with AJAX - parseerror - works on IIS 5.1

    Hehe - sometimes it amazes me how small the net can be.

    Anyhow - it didn't work for me to comment out that code line like so:

    ' Response.ContentType = "text/html"
    ' Response.AddHeader "Content-Type", "text/html; Charset=UTF-8"
    Response.CodePage = 65001
    Response.CharSet = "UTF-8"   

    Can anyone on the IIS team respond to this thread? I'm working on a freshly installed Windows 2008 server here - and to me, this looks like something that affects many people. I have also experienced this problem on other Windows 2008 servers, so this is no unique to this project.

    Kind regards,
    nitech

  • 03-17-2009, 3:16 AM In reply to

    • nitech
    • Not Ranked
    • Joined on 03-13-2009, 7:03 AM
    • Posts 5

    Re: Weird IE error with AJAX - parseerror - works on IIS 5.1

    Allright. With anilr's help, I figured out what the problem was, and I'll try to help you too, in case you've bumped into the same problem

    The problem is, as anilr said, that you've done Response.ContentType and/or Response.CharSet multiple times, also maybe combined with Response.AddHeader "Content-Type", "text/html; Charset=UTF-8" which basically does the same as the two other statements.

    To find out what's happening when you run your asp-file, you can turn on Failed Request Tracing. I thought the Failed Request Tracing would just log failed requests. And since the request in deed worked on other browsers than IE7, I figured it would not help me to log failed requests. Don't misunderstand this as I did. You can set up the Failed Request Tracing to log any requests. And that's what we'll do.

    First, follow this tutorial: http://www.trainsignaltraining.com/iis-7-troubleshooting/2008-07-09/

    You'll set up a failed request tracing rule on the specific site, tracing ASP-files on status codes 100-999. Then you'll go to the site in IIS manager and click the rightmost option "Failed Request Tracing". If you're used to IIS6, you'll probably have a little hard time finding your way around the new MMC interface. The Failed Request Tracing set up for the site is not one of the icons - but it's located to the right of the icons, written with just text. There you'll enable tracing and set an output directory.

    Now fire up your browser and trigger the Ajax-call. The tracer will make an XML-file for you on the specified directory. Open it in your favorite editor and search for <Data Name="Headers">. You'll probably find two or more. Check the last one, and see what it outputs. It should output something like this:

    Content-Length: 89
    Content-Type: text/html; Charset=UTF-8
    Expires: Fri, 31 May 1996 11:30:14 GMT
    Server: Microsoft-IIS/7.0
    X-Powered-By: ASP.NET

    Before I fixed my problem, however, it output this:

    Content-Length: 89
    Content-Type: text/html;charset=UTF-8,text/html; Charset=UTF-8
    Expires: Fri, 31 May 1996 11:30:14 GMT
    Server: Microsoft-IIS/7.0
    X-Powered-By: ASP.NET

    The reason was that I had a Response.AddHeader in two different files.

    I hope this will help somebody else too.
    Kind regards,
    Nitech

Page 1 of 1 (9 items)
Microsoft Communities