views:

197

answers:

4

Interesting one here. I have an ASP.NET 1.1 project that contains a web service in it. I'm using jQuery's AJAX functionality to call some services from the client. This is what my code looks like:

$.ajax({
    type: "POST",
    url: 'foo.asmx/functionName',
    data: 'foo1=' + foo1 + '&foo2=' + foo2,
    dataType: "xml",
    success: function(xml) {
        //do something with my xml data
    },
    error: function(request, error){
        //handle my error

    }       

});

This works great when I run the site from my IDE on localhost. However, when I deploy this site to any other server I get a parsererror error from jQuery. It does not appear to even call my service as I dropped in some code to write a log file to disk and it's not making it there.

The same exact XML should be returned from both my localhost and the server I deployed to.

Any ideas?

A: 

Are you sure that foo.asmx gets you to the proper location, did you change folder structures at all?

Mitchel Sellers
It's the correct path. No changes when deployed. I even tried hard coding the path to see if this was the cause but no dice. Same error.
Alex
+1  A: 

What do you mean "parsererror" from jQuery?

My first two passes would be:

1- use firebug to get more error details http://encosia.com/2009/03/04/use-jquery-to-catch-and-display-aspnet-ajax-service-errors/

2- convert your data string to a json object '{"foo1":"bar1","foo2":"bar2"}'

Joseph Connolly
A: 

Have you examined the XML that's being returned when the application is deployed to make sure that it's the same?

For those who are wondering when you'd get a jQuery parse error, it looks like it's related to XML-returning web services: http://groups.google.com/group/jquery-en/browse_thread/thread/a97f10ae30824fba?pli=1

Cory Grimster
A: 

I found the answer to this. After some debugging with Firebug I noticed that the server was throwing back some error HTML. I looked at my server side error logging and the exception was "Request format is unrecognized."

After a bit of digging around I discovered that the following change to the web.config corrects the error:

<system.web>                
<webServices>
    <protocols>
        <add name="HttpGet"/>
        <add name="HttpPost"/>
    </protocols>
</webServices>
</system.web>

Now I am a bit interested in the fact that my localhost does not have that web.config entry and works regardless. If anyone understands that a little better I'd like to know why.

Thanks for all the suggestions.

Alex