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: funct开发者_StackOverflow中文版ion (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.
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()
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.
精彩评论