...

View Full Version : Form submit with-out re-submit on back button?



wh333t
08-13-2011, 01:58 AM
Hey CF,

I'm brand spankin new to the forums. I think I'll get comfortable around here.

My first question goes something along the lines of this:

I want to be able to submit a form, and have the page refresh (like a normal form submit) but if the user hits the back button, I don't want it to ask them to resend the post data. I have seen many popular websites do this such as Plentyoffish.com.

Are these websites just submitting a form using Ajax and then using a javascript re-direct? If so, please explain how I can use ajax to change the url. My understanding of Ajax is quite minimal but I've never managed to make Ajax do anything except send data and then request data, I've never been able to make it control the browser.

If they aren't using Ajax (hopefully there is a simpler technique) I would love to learn about it.

Thanks for reading!

fthomas137
08-13-2011, 07:49 AM
I'd actually like to figure this one out too. I have a client that gets stuck on this particular problem when pulling stock numbers.

wh333t
08-13-2011, 08:18 AM
I'd actually like to figure this one out too. I have a client that gets stuck on this particular problem when pulling stock numbers.

I know, you'd think this would be something that would have been commonly address along time ago.

wh333t
08-13-2011, 09:23 AM
I'd actually like to figure this one out too. I have a client that gets stuck on this particular problem when pulling stock numbers.


[spam]

I see these forums aren't moderated?

VIPStephan
08-13-2011, 12:48 PM
I see these forums aren't moderated?

They are but itís weekend and not everybody is around 24/7. Thatís why we have the report feature so moderators are notified by e-mail. As with everything on these forums: be patient and you will be helped. ;)

wh333t
08-13-2011, 08:47 PM
They are but itís weekend and not everybody is around 24/7. Thatís why we have the report feature so moderators are notified by e-mail. As with everything on these forums: be patient and you will be helped. ;)

I understand. I actually hit the report post button after. :):thumbsup:

wh333t
08-15-2011, 09:15 PM
* Bump *

Surely someone has some info to share on this matter.

wh333t
08-17-2011, 01:30 AM
* Bump * :(

wh333t
08-19-2011, 09:14 AM
Bump :(!

alykins
08-19-2011, 03:45 PM
you are not getting answers because this has nothing to do with html/CSS... can you link a site that you have seen this working? then ask for help determining how exactly it is done (ie javascript, server-side (and what language) ) and then we (moreover you) can then PM a moderator to move this thread to the appropriate section of the forum.

wh333t
08-19-2011, 08:34 PM
you are not getting answers because this has nothing to do with html/CSS... can you link a site that you have seen this working? then ask for help determining how exactly it is done (ie javascript, server-side (and what language) ) and then we (moreover you) can then PM a moderator to move this thread to the appropriate section of the forum.

I put it in HTML/CSS at first because I figured it might be an HTML 5 thing. I later thought it must be some kind of Javascript trick but I didn't want to double post (that's a no no on forums right?).

The website where I've seen it work is Plentyoffish.com The website I'm working on unfortunately I can't show because it's inside the management area, but it's nothing special, just a bunch of forms with regular submit buttons and such.

skywalker2208
08-19-2011, 11:57 PM
I am thinking they are using server side code to do a redirect to the same page or a different page after the form has been process to clear out any post/get data.

wh333t
08-20-2011, 12:03 AM
I am thinking they are using server side code to do a redirect to the same page or a different page after the form has been process to clear out any post/get data.

Hrmmm, I don't think so. I think this is a client side thing because no amount of Server Side scripting can change the functionality of the browser (not that I'm aware of at least, that sounds like a huge security risk). I'm quite confident it's all done on the client side, but oddly not many people seem to be able to pull this kind of thing off.

It's quite easy to direct to different pages with serverside scripting, but how does that prevent the browser from re-submitting data when you hit back buttons? All that information and the desire to re-submit the data is part of how the browser functions, to my knowledge at least.

I appreciate the response anyhow :D

alykins
08-20-2011, 01:09 AM
Hrmmm, I don't think so. I think this is a client side thing because no amount of Server Side scripting can change the functionality of the browser (not that I'm aware of at least, that sounds like a huge security risk). I'm quite confident it's all done on the client side, but oddly not many people seem to be able to pull this kind of thing off.

It's quite easy to direct to different pages with serverside scripting, but how does that prevent the browser from re-submitting data when you hit back buttons? All that information and the desire to re-submit the data is part of how the browser functions, to my knowledge at least.

I appreciate the response anyhow :D

it can be done... and actually is more secure... I can for example make certain xml tags in my config file and when you do some action I can pull that data and store it in my config... now this is even more secure than your cookies or cache or w/e... or i could take it and throw it into a database. client side storage of data is IMO unsafe... serverside is a lot more secure and I bet it is being done that way... now as to what language it is in... there is an extension embedded in the page "index.aspx" which means it is an aspx page and i have no clue what second tier language... Also unfortunately, granted i love this forum, it seems to be a more open source oriented forum and idk if you will get too much help doing so... you may find help figureing it out in the php section but idk much about php... I imagine if you PM Apost or VIP they would move you... if not I have seen Fou (php mod) move many threads; maybe he will. best of luck

wh333t
08-20-2011, 01:26 AM
it can be done... and actually is more secure... I can for example make certain xml tags in my config file and when you do some action I can pull that data and store it in my config... now this is even more secure than your cookies or cache or w/e... or i could take it and throw it into a database. client side storage of data is IMO unsafe... serverside is a lot more secure and I bet it is being done that way... now as to what language it is in... there is an extension embedded in the page "index.aspx" which means it is an aspx page and i have no clue what second tier language... Also unfortunately, granted i love this forum, it seems to be a more open source oriented forum and idk if you will get too much help doing so... you may find help figureing it out in the php section but idk much about php... I imagine if you PM Apost or VIP they would move you... if not I have seen Fou (php mod) move many threads; maybe he will. best of luck

Either I'm misunderstanding you, or you are misunderstanding me.

How does a server side language prevent the browser from acting the way it's designed too? In this case, prevent the browser from re-submitting form data. I've never witnessed any server side language that could manipulate the default behavior of the browser, if it's possible to do so, that's why I said it seemed like a security risk.

I don't know much about ASP, it's a Microsoft technology and I've learned to stay away from them.

I will PM them and see what they can do, thank you for responding.

wh333t
08-20-2011, 01:29 AM
it can be done... and actually is more secure... I can for example make certain xml tags in my config file and when you do some action I can pull that data and store it in my config... now this is even more secure than your cookies or cache or w/e... or i could take it and throw it into a database. client side storage of data is IMO unsafe... serverside is a lot more secure and I bet it is being done that way... now as to what language it is in... there is an extension embedded in the page "index.aspx" which means it is an aspx page and i have no clue what second tier language... Also unfortunately, granted i love this forum, it seems to be a more open source oriented forum and idk if you will get too much help doing so... you may find help figureing it out in the php section but idk much about php... I imagine if you PM Apost or VIP they would move you... if not I have seen Fou (php mod) move many threads; maybe he will. best of luck

I just attempted to PM both of those users. It said unable to find those usernames >.>?

Apostropartheid
08-20-2011, 01:45 AM
I think he meant me.

I would move this thread but I'm not too sure where I would move it to: it seems too messy. From what I can decipher, you want to use AJAX to submit a form. If this is the case, try it out and post in JS if you encounter any problems.

wh33t
08-20-2011, 01:50 AM
I think he meant me.

I would move this thread but I'm not too sure where I would move it to: it seems too messy. From what I can decipher, you want to use AJAX to submit a form. If this is the case, try it out and post in JS if you encounter any problems.

Aye, it's a pretty messy thread. Let me clear up what it is I want to be able to do and I'll let you fill in the blanks.

I want to be able to submit form that still causes a page refresh or goes to a new page (like normal), HOWEVER if/when a user clicks the back button on their web browser it DOESN'T repost the information.

In my original post I suggested that this could probably be done with Ajax (at least the form submission), but how do you then make Ajax go to a new page after the form has been submitted, ensuring that the ajax request has had enough time to complete the request? I've never witnessed or heard of Ajax being able to control page re-direction after an event. But if it's possible I'd love to see it done.

Now that you know, you can let me know what you think.

Apostropartheid
08-20-2011, 01:53 AM
Aye, it's a pretty messy thread. Let me clear up what it is I want to be able to do and I'll let you fill in the blanks.

I want to be able to submit form that still causes a page refresh or goes to a new page (like normal), HOWEVER if/when a user clicks the back button on their web browser it DOESN'T repost the information.

In my original post I suggested that this could probably be done with Ajax (at least the form submission), but how do you then make Ajax go to a new page after the form has been submitted, ensuring that the ajax request has had enough time to complete the request? I've never witnessed or heard of Ajax being able to control page re-direction after an event. But if it's possible I'd love to see it done.

Now that you know, you can let me know what you think.

JavaScript can control redirection with the window.location method. I'm not sure there would be a request for a repost unless you've actually redirected twice: once from the "processing" page and one to a "thank you" page.

alykins
08-20-2011, 02:37 AM
i am still really confused by what exactly you want... couldnt you just have your entry fields blank and do a validation? if there is no data then do not submit... then who cares how many times it's press-ed "back" or refresh or whatever... just throw the re-post "data" (ie the blank text fields) as invalid and do not post to your DB



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum