Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form POST request returns previous data - refresh problem 1

Status
Not open for further replies.

spiderplant0

Programmer
Oct 4, 2010
6
GB
Hi, I'm having problems fetching data from a server. I have a web page that makes a request for an image file. The particular image returned depends on the 'quadkey' input. See code below.
The problem is, each time I request a new image, Firefox prefers to display the old image.
E.g. when I press 'submit' a png image is displayed properly. If I then press the browsers 'go-back' button, enter a different number for the quadkey form input (e.g. replace the '03113322201' with '03113332000') and press 'submit' again the browser just displays the same image as before. I have to hit 'F5' to force the browser to display the new correct image. Even flushing the cache inbetween times doesnt help. I think part of the problem is due to the image being returned with the same filename each time.
Is there something wrong with my FORM command or is there something I can add to force it to get the new image?
Code:
<html>
<head>
</head>
<body>

    <p>Test values for quadkey: 03113332000 03113323100 03113323010 03113322201</p>
    <form
        action="[URL unfurl="true"]http://go.mappoint.net/sepa/Services/TileServiceSql2005.ashx"[/URL]
        method="post">
        <input type="text" name ="quadkey" value="03113322201">
        <input type="text" name ="type" value="Default">
        <input type="submit">
    </form>

</body>
</html>
I have experimented with adding a javascript reload() command which works, but this causes a 'To display this page, Firefox must send information' pop-up to appear each time. So I could solve the problem this way if there was a Firefox configuration to stop this pop-up appearing.
 
I would recommend adding a [tt]?{random_number}[/tt] at the end of your image URL (e.g. [tt]<img src="myImage.png?458912" />[/tt]). This usually forces browser to fetch the image every single time, as it believes it is a new image. Find a way in your scripting language to add a random string.

[small]Do something about world cancer today: Comprehensive cancer control information at PACT[/small]
 
Thanks vragabond that worked.
Code:
<html>
<head>
</head>
<body>

    <p>Test values for quadkey: 03113332000 03113323100 03113323010 03113322201</p>
    <form
        method="post">
        <input type="text" name ="quadkey" value="03113322201">
        <input type="text" name ="type" value="Default">
        <input type="submit">
    </form>

<script type="text/javascript">

    document.forms[0].action =
        "[URL unfurl="true"]http://go.mappoint.net/sepa/Services/TileServiceSql2005.ashx"[/URL] +
        "?" + Math.random();

</script>
</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top