views:

310

answers:

1

I just made quite a large update on a website that uses asp.net. In the new update I have changed a lot of the code so that I use jquery instead together with asp.net web service. Many of my users have problems with that the new update doesn't work until they flush all cache in their browser. As it's a lot of work to tell everybody to flush their cache, maybe I can force a flush when they load the new update?

A typical ajax call that the user have problems with is:

$.ajax({
    type: "GET",
    url: url,
    dataType: "json", cache: false, data: "{}", contentType: "application/json; charset=utf-8"....

On the server machine I log the errors and it looks like this:

Error Message: There was no channel actively listening at 'http://www.domain.com/Service.svc/get?date=2010-01-12&_=1263327373122&{}'. This is often caused by an incorrect address URI. Ensure that the address to which the message is sent matches an address on which a service is listening.

The "_=1263327373122" part shouldn't be there at all.. When the user have flushed their cache it works perfect again. How can I fix this problem?

+2  A: 

If you don't want to send any data, just omit the data parameter or change it to data: {} (without quotes). It thinks you want to send the string "{}".

The parameter _ is sent because you specified cache: false.

Besides, I think you should not 'build' the URL with the parameters yourself and pass an empty data object. jQuery does it for you.

i.e. Instead of

$.ajax({
    type: "GET",
    url: "http://mydomain/service?date=" + mydate,
    data: {} });

Do this

$.ajax({
    type: "GET",
    url: "http://mydomain/service", //this remains constant
    data: {date: mydate} });
Chetan Sastry
So I can send my parameters using "data" even if it's a get and not a post?
Martin
Yes, it will be converted to query string if it's not a string already
Chetan Sastry