Reputation: 3
I'm beginner of Programming. I'm trying to make movie booking web site. and I was tried to making my page. on "My page-booking" i made button for cancel booking. if i press cancel booking button, if movie start time is remain over 30min, i can cancel movie book, or if movie start time is remain less then 30min i can't cancel book.
Canceling Booking is working properly, but less than 30min cancel button is not working properly. if i press button, it redirect to main mypage. (when remain time is less then 30min) but i want to return last page..
ps. My English is not good enough to explane.. sorry for that :(..
I already tried "return false;" but it doesn't work.
$.ajax({
type:'post',
url: "/Movie/Reserve_Cancel.movie",
data: {time_startdate: 'time_startdate', time_starttime: 'time_starttime', time_screencode: 'time_screencode', reserve_id: 'reserve_id', reserve_seatcount: 0},
success: function (data) {
alert(data)
alert('You cannot cancel you're reservation.');
}
})
Upvotes: 0
Views: 40
Reputation: 29
I read this question and implemented the approach that has been stated regarding setting the response status code to 278 in order to avoid the browser transparently handling the redirects. Even though this worked, I was a little dissatisfied as it is a bit of a hack
$.ajax({
type: "POST",
url: reqUrl,
data: reqBody,
dataType: "json",
success: function(data, textStatus) {
if (data.redirect) {
// data.redirect contains the string URL to redirect to
window.location.href = data.redirect;
}
else {
// data.form contains the HTML for the replacement form
$("#myform").replaceWith(data.form);
}
}
});
Upvotes: 0