Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Submit a form with FormData in jQuery - without Ajax and without hidden fields

I have a function which does some custom work on form submit, send some data via Ajax, append the returned data in a new FormData object, now I need to submit the form conventionally (not via Ajax) with this FormData. I understand that it can be achieved with hidden fields, but what if I don't want the returned data to be visible to someone who knows a little bit of coding ?

So is it possible to submit a form with a custom FormData in jQuery without the hidden fields and Ajax ?

like image 255
StudentX Avatar asked Aug 14 '15 16:08

StudentX


Video Answer


1 Answers

You could add your object into the form before submitting it and the remove it directly afterwards.

$('#yourForm').submit(function() {
    $(this).append(yourCustomObject)
    $(this).submit();
    $(yourCustomObject).remove();
});
like image 58
Jens Hunt Avatar answered Oct 01 '22 19:10

Jens Hunt