I have a form I'm submitting via ajax POST, which on original submission shows as Array(74)[Object, Object, Object,...], but then if user loses connection, I store this info in a cookie to re-run on page load (connection re-established). However, when I go to process after reconnected/loaded, the cookie decides to store the data as [object Object],[object Object],[object Object],object Object..
Can someone explain what's happening here, and help me rectify?
Cheers
Example:
function submitOrder() {
var postData = $('#form_name').serializeArray();
var cookieName = "cookieName_" + $('#the_id').val();
if(isonline()) {
$.ajax({
url: 'process_order.php',
type: 'POST',
data: postData,
success: function () {
signatureSave(0);
window.location = "index_2.php";
alert("Work Order Submitted!");
},
failure: function () {
signatureSave(0);
setCookie(cookieName, postData);
window.location = "index_2.php";
alert("Work Order Pending - Please check connection!");
},
error: function () {
signatureSave(0);
setCookie(cookieName, postData);
window.location = "index_2.php";
alert("Work Order Pending - Please check connection!");
}
});
}}
function setCookie(cname, cvalue) {
var d = new Date();
d.setTime(d.getTime() + (365*24*60*60*1000));
var expires = "expires=" + d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
function checkForCookies() {
if (getCookie("cookieName_").toString() != "") {
var cookie = getCookie("cookieName_");
var key = cookie.substring(0, cookie.indexOf("="));
var value = cookie.substring(cookie.indexOf("=") + 1);
console.log(value);
$.ajax({
url: 'process_order.php',
type: 'POST',
data: value,
success: function() {
alert("Pending order submitted...");
deleteCookie(key);
checkForCookies();
}
});
}
}