Mikejh99
Mikejh99

Reputation: 368

jQuery/AJAX is working on IIS5.1 but not IIS6

I'm running a weird issue here. I have code that makes jquery ajax calls to a web service and dynamically adds controls using jquery. Everything works fine on my dev machine running IIS 5.1, but not when deployed to IIS 6. I'm using VS2010/ASP.Net 4.0, C#, jQuery 1.4.2 and jQuery UI 1.8.1. I'm using the same browser for each.

It partially works though. The code will add the controls to the page, but they aren't visible until I click them (they aren't visible though). I thought this was a css issue, but the styles are there too.

The ajax calls look like this:

$.ajax({
            url: "/WebServices/AssetManager.asmx/Assets",
            type: "POST",
            datatype: "json",
            async: false,
            data: "{'q':'" + req.term + "', 'type':'Condition'}",
            contentType: "application/json; charset=utf-8",
            success: function (data)
            {
                res($.map(data.d, function (item)
                {
                    return {
                        label: item.Name,
                        value: item.Name,
                        id: item.Id,
                        datatype: item.DataType
                    }
                }))
            }
        })

Changing the content-type makes the autocomplete fail. I've quadruple checked and all the paths are correct, there is no document footer enabled in IIS, and I'm not using IIS compression.

Any idea why the page will display and work properly in IIS 5 but only partially in IIS 6? (If it failed completely, that'd make more sense!). Is it a jQuery or CSS issue?

EDIT: I'm using "contentType: "application/json;" charset=utf-8" I copied a test call that had application/javascript.

@Gaby: I'm well aware of the fact that the server has nothing to do with CSS or javascript, however, that is the only difference between the code that does and doesn't work.

All the jquery/css files are identical between my local dev machine (IIS 5) and the server (iis 6).

@jaymz: I'll give fiddler a try to see if there's a difference. I am using IE8 but it isn't going into compatibility mode.

SOLUTION: (Compatbility Mode!) After checking everything in Fiddler and finding no differences, I tried it in Firefox, where it worked. Got me to thinking and sure enough, I was wrong, IE WAS going into compatibility mode. apparently by default it will use compatibility mode on the intranet, but not localhost (which happened to be the different versions of IIS). I tried IE7 and got the same thing. I need to change my code to make sure it works on IE7 as well.

Upvotes: 1

Views: 2706

Answers (2)

Jaymz
Jaymz

Reputation: 6348

Have you run the request through with a tracer? Try using Fiddler in IE, and see if the headers/content is being returned differently from the 2 different servers.

Off the top of my head, I can only think that IE (if it's IE8, you didn't mention what browser you were using), is using Compatability mode when it sees IIS 5, but not for IIS 6. I could be way out with that, but the headers should give you more of an idea of what's different.

Upvotes: 2

Ray Lu
Ray Lu

Reputation: 26668

Double check if you have deployed everything onto the server with IIS 6 e.g. jQuery 1.4.2 and jQuery UI 1.8.1 etc

Upvotes: 0

Related Questions