I am using smoothState.js and I am having an issue with submitting a form and then reloading (refreshing) the page.
When I submit the first time it works as expected. The page refreshes with the new/changed data in the inputs. But when I submit it the second time, the data apparently gets posted, but on the refresh the old unchanged data gets loaded. It is only after I do a manual refresh (click on the refresh button in the browser again) is when the new changed data appears. This only happens on the second/third/fourth etc... submit on the same form to the same page.
$('#companyProfile').submit(function(e) {
e.preventDefault();
if ( $(this).parsley().isValid() ) {
var $form = $("#companyProfile");
$.ajax({
type : "POST",
async : true,
url : '/customerProfile.do?',
data : $form.serialize(),
success : function(data) {
console.log("Submit happened");
var smoothState = $('#main-cont').smoothState().data('smoothState');
smoothState.load(window.location.reload);
}
});
return false;
}
});
I have added a console.log("Submit happened");
and what happens with that is that the first time the post is submitted the source is viewOrderSettings.jsp
as it should be, but the second time it is from VM34065:11
as seen in the screenshot below. If that helps ...