I have an application. When a user clicks "Add to Cart" or "Save Project" it calls the appropriate url to save the data and then redirects the user to the correct page:
if (add_to_cart == true) //If we are adding to cart
{
$.ajax
(
{
//Note: tf_cart.module must contain $_POST['app'] $jpg = xmlp_f_save_jpg($_POST['file'], $_POST['app']);
type: "POST",
processData: false,
url: SITE_URL + "/system/atc/" + app_type + "/0/" + session_id + "/0/?prjid=" + project_id, //send data to this url
data: "xml=" + common_order_xml + "&prodid=" + product_id + "&file=" + image.src + "&rid=" + revision_id + "&cid=" + cart_id + "&app=html5" //send these as post variables to the url
}
).done(function(msg) //When we get a response from the server after we POST
{
//console.log("Project added to cart. "); //This is for testing the canvas element on screen - leave this code here
window.location = SITE_URL + "/cart/?pid=" + partner_id; //Send the user to the cart page
});
}
else //If we are saving the project
{
$.ajax
(
{
//Note: xmlproject.module must contain $_POST['app'] $jpg = xmlp_f_save_jpg( $_POST['file'], $_POST['app'] );
type: "POST",
processData: false,
url: SITE_URL + "/system/xml/import/" + app_type + "/" + session_id + "/?prjid=" + project_id, //send data to this url
data: "xml=" + common_order_xml + "&prodid=" + product_id + "&file=" + image.src + "&app=html5&rid=" + revision_id //send these as post variables to the url
}
).done(function(msg) //When we get a response from the server after we POST
{
var parser = new DOMParser(); //create a new DOMParser
var doc = parser.parseFromString(msg, "application/xml"); //convert the string to xml
pid = doc.getElementsByTagName('pid')[0].childNodes[0].nodeValue; //Get the pid (project id) from the xml
rid = doc.getElementsByTagName('rid')[0].childNodes[0].nodeValue; //Get the rid (revision id) from the xml
//console.log("Project saved. " + " pid=" + pid + " rid=" + rid); //This is for testing the canvas element on screen - leave this code here
window.location = SITE_URL + "/user/mystuff/projects/view/" + pid + "/?pid=" + partner_id; //Send the user to this project's page
});
}
The issue I have is once the user is either at the Project Page or the Cart page and they hit the back button, it returns them back to the application with a blank project. What I want to happen is when they hit the back button, that project gets loaded.
I'm not sure how to go about this... any ideas?