Best way to POST Form data, File via jQuery AJAX

Coders Den

In programming, you often required to POST form data via jQuery AJAX. Posting normal data via AJAX is the easiest task. But Posting an image, File through AJAX is quite tricky. Either you need to include plugin/library that does the same job or you need to do RD on this. But in some projects, you do not want to include those plugins/libraries.

Here in this article, I will show you how you can POST your form data, image or FILE easily. Make this your habit in programming to call AJAX in this way and you will never face such problems. You will get your all data (normal data, image, FILES) on server side language.


HTML File / Form

Javascript File

save-data.php

In my PHP file, I am just printing the POST data & FILES. I will print the form’s all data & FILES.

Leave a Reply