To take the data from the form?

The site has a feedback form.

Data sending occurs without reloading the page using

$('#osForm').submit(function(e) {
e.preventDefault();
$.ajax({
 url: "mail.php",
 type: "POST",
 data: $('#osForm').serialize(),
 success: function(response) {
$.fancybox.close();
$.fancybox.open({
 src: '#p_ok',
 type: 'inline',
});
},
 error: function(response) {
 //error handling when sending
}
});
});


But I need to verify the name of the form framed in the window #p_ok which POPs up after you submit the form with the success message.

How can I do?
March 23rd 20 at 18:46
1 answer
March 23rd 20 at 18:48
$.fancybox.open({
 src : '#p_ok',
 type : 'inline',
 opts : {
 afterShow : function( instance, current ) {
 // suppose you have a tag with id=username inside #p_ok
 document.querySelector('#p_ok #username').textContent = '<Here insert name>';
}
}
 });

Find more questions by tags JavaScriptAJAX