views:

170

answers:

2

Just started getting into jQuery and have an issue with a jQuery Post call working perfectly on my local dev box (VS 2008 built-in web server), but failing when I deploy to a windows 2003 server (IIS 6) box.

The post works and the page being posted to process things correctly, but a response is never received by the calling Post function. The submitting page just reloads with no changes.

Here is my Post function (it is enclosed in the $(document).ready(function() {... The alert in the response function never fires:

        $('.nextButton').click(function() {

            var idString = '';

            $("div.dropZone > div").each(function(n) {
                idString += this.id + '|';
            });

            $.post('CustomPostHandler.aspx?step=criteria', { 
                selected: idString
            },
                function(data) {
                    alert(data);
                });
        });

The post handler page does receive the idString variable fine, after some processing it attempts to write back a response:

        // Return dummy response to caller
        Response.Clear();
        Response.ContentType = "text/plain";
        Response.Write("success");
        Response.End();

I've checked the deployment server environment and don't see anything missing (this is running against the 3.5 SP1 framework). Anyone have any ideas or am I missing something?

+1  A: 

The problem is probably due to caching.
Try adding a random number to the post URL

$.post('CustomPostHandler.aspx?step=criteria&random=' + Math.random().toString(), { 
            selected: idString
        },
Eduardo Molteni
Thanks for the response, added the random # as you suggested. Still no response coming back. For the short term, I've just decided to ignore any response and just reload the page to pick up the updated server info. Not ideal but ok for now.
Harrison
A: 

I agree that is probably due to caching. The more general $.ajax function allows you to set the cache option to false in order to disable caching.

Have a look at the documentation.

kgiannakakis