/    Sign up×
Community /Pin to ProfileBookmark

AJAX: changing GET into POST result into page not found error

Hi All

I noticed that my ajax calls were cached by the browser. However I want to do an ajax call over and over again, retrieving the data from the server, not from the browser’s cache

I red somewhere that you can change ‘GET’ into ‘POST’, because the browser doesn’t cache POST-requests.

Here is my code (snippet):

[code]
xmlDoc = new window.XMLHttpRequest();
xmlDoc.open(“GET”, “config.xml”, false);
xmlDoc.send(null);
[/code]

changing ‘GET’ to ‘POST’ results in a page not found (404) error. Any suggestions?

Thnx a lot
LuCa

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@aj_nscDec 06.2008 — I ran into this trouble before too, I make the same ajax call over and over again, however, I don't want it cached. There are object parameters you can set, but the way I do it is to append the "url" variable you are sending with the current unix time every time a request is sent, this tricks the browser into thinking that this ajax call wasn't made before and therefore, the response wouldn't be cached.

Like this:
<i>
</i> now = new Date();
url = "yoururl.php?plus=your&amp;parameters=here";
url = url+now.getTime();

//send your request here
Copy linkTweet thisAlerts:
@jeanlucaauthorDec 06.2008 — great solution, thnx!!
×

Success!

Help @jeanluca spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...