Ajax asynchronous processing post form data sample code

Time:2021-5-10
//Prevent page from jumping

$(document).ready(function(){
$("#submit").click(function(){
var str_data=$("#form1 input[type=text]").map(function(){
return ($(this).attr("name")+'='+$(this).val());
}).get().join("&");
var box_data=$("input[type=checkbox]:checked").map(function(){
return ($(this).attr("name")+'='+$(this).val());
}).get().join("&");
var race=$("#race").val();
var volume=$("#volume").val();
str_data+="&volume="+volume;
str_data+="&race="+race;
str_data+="&"+box_data;
$.ajax({ 
type: "POST",
url:"deal.php",
data:str_data,
success: function(msg){
$("#myModal .modal-body").html(msg);
}
});
});
});