6

I'm developing a Firefox extension that uses an ajax-request to retrieve information. This is the code:

$.ajax({
        url: "http://127.0.0.1/foo/bar/Service?wsdl" + new Date().getTime(),
        beforeSend: function(request) { request.setRequestHeader("SOAPAction", "Group"); },         
        async: false,
        cache: false,
        type: "POST",   
        dataType: "xml",
        data: req,
        contentType: "text/xml; charset=\"utf-8\"",
        success: function (data, textStatus, xmlHttpRequest) {
        out = $(xmlHttpRequest.responseXML);
        }
    }); 

I still get the same result, when the data that is sent to the server is changed. I tried to avoid that by adding "new Date().getTime()" to the URL and "cache: false". This doesn't seem to work. After restarting the browser, I get the correct results.

Does anyone have an idea what the problem is? Is there some kind of session-handling, so the server still gives back the old response?

Edit: I did a lot of testing and debugging and I think I found the problem: there is a cookie saved with every ajax-request that contains a session-id, so every time I do the request again, the server sends data of the session with the session-id in the cookie. Really bad behavior, I didn't know that cookies could be created through an ajax-request. So everything I have to do to fix the problem is a function that deletes this cookie every time my parameters are changed. Thanks for your help again.

4
  • did you try any of those suggestions ?? Commented Dec 4, 2010 at 23:09
  • Yeah, i tried both suggestions now (by Dr. Molle and by gov), but the behavior is still the same. Commented Dec 4, 2010 at 23:43
  • 1
    is it , are you doing any caching on server side ??? Commented Dec 4, 2010 at 23:56
  • I don't have any influence on what is done on server side, but I already checked that with a SOAP client and the replies were correct. Commented Dec 5, 2010 at 9:50

2 Answers 2

8

Can you try this

$(document).ready(function() {
  $.ajaxSetup({ cache: false });
});

try toger with Math.random() to be on safer side

Date().getTime() together with Math.random()

http://127.0.0.1/foo/bar/Service?wsdl" + new Date().getTime() + Math.random()
Sign up to request clarification or add additional context in comments.

Comments

1

Try an ampersand before the timestamp:

http://127.0.0.1/foo/bar/Service?wsdl&" + new Date().getTime()

I guess the wsdl-parameter makes sense there inside the url, without the ampersand you destroy the parameter.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.