Redirect using jQuery on specific days, at specific times?

Go To


Anyone know of a way to fire a page redirect on pre-programmed days / times / time ranges? My client is a theater with an online "box office", and they want online ticket sales to end at specific times before shows, then re-open the next morning.

For example, the shows are on Fridays at 7:30. They prep the theater at 4, and there is no internet access there (it's remote). So between 4 and 7:30 they can't process new online orders. If someone arrives with a confirmation number from an online sale made after 4, they won't have a record of the purchase. This causes overbooking, lost money, etc.

I'd like the user to have access to the show dates page (with buttons to purchase tickets), and when they click a button, if the box office is closed, I'd like to redirect them to a page offering a discount, buying alternative, contact information, etc.

I'd also like to stick with jQuery as I'm most comfortable in that environment.

Anyone know of a viable option? Thanks for reading!

2012-04-04 19:16
by JordanDBP
this asks for a server side check! Compare the current date/time of the server with the date/time of the show (you can do this with a single database query).

Don't rely on the time of the client - huysentruitw 2012-04-04 19:19

When they hit the button, you can use an AJAX call to check against the database if online ticketing is till open for the given show. Depending on the result you could redirect the user - huysentruitw 2012-04-04 19:22
Derp. I knew that. Thanks. I come from OSX land, where things like date and time are universally set. Anyone using the page is located in about a 300 mile radius, so not too worried about varied client times. Ah well - JordanDBP 2012-04-04 19:22
@JordanDBP even on OSX land, you can't rely on client time at all. It could be easily changed - Alex Turpin 2012-04-05 14:51


Its sounds like it would be good if you do the following:

//client side

  1. create an object of films and their times
  2. store current time in a var
  3. check to see that current time doesn't overlap with one of the movie times
  4. not allow them to view a page (via redirect using window.location or something else) if overlap is occurring for a particular movie

//server side

  1. also do a check of time overlap so you can reject an order attempt that is at a wrong time. // this is necessary because js could fail, your validation would not stop the transaction, and the page could submit
2012-04-04 19:21
by Kristian
client side point 3 requires you to do a time conversion between the timezone of the client and timezone of the show location. This will cause you more trouble then asking it kindly to the server - huysentruitw 2012-04-04 19:26
sure, but if you're in a different timezone, you're not going make it to the movie, probably. ; - Kristian 2012-04-04 20:58