Is there a way to record a successful client-side form submit event with jQuery without making a request or posting data for testing? Or, put another way, is there a way to separate the submit event from the post request? For example, say I've got:
$(document).ready(function(){
$(".myForm").submit(function(e){
e.preventDefault();
$.post(
"url",
$(this).serialize(),
function(data){
console.log("Form success")
}
);
});
});
How could this be re-writtern to record the form submit but not send data? I can set the form submit button to onclick="trackClickFunction()" but that just confirms the button was clicked. Can ajax() accomplish this? thanks
Maybe something like this:
var savedVars;
$(document).ready(function(){
$(".myForm").submit(function(e){
e.preventDefault();
savedVars = $(this).serialize();
});
});
THen you'll have access to the serialized values globally in savedVars
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.