# How to send 2 requests in HTML / Javascript?

**URL:** https://forum.kirupa.com/t/how-to-send-2-requests-in-html-javascript/636484
**Category:** web dev
**Created:** [April 22, 2017, 8:31pm UTC](https://forum.kirupa.com/t/how-to-send-2-requests-in-html-javascript/636484 "2017-04-22T20:31:34Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![HarryPorter](https://avatars.discourse-cdn.com/v4/letter/h/8dc957/32.png) [@HarryPorter](https://forum.kirupa.com/u/HarryPorter)
#### Post date: [April 22, 2017, 8:31pm UTC](https://forum.kirupa.com/t/how-to-send-2-requests-in-html-javascript/636484/1 "2017-04-22T20:31:34Z")

</div>

I currently have a form that uploads file to a server the files are uploaded using the regular “multipart/form-data” and method=“POST”. I also am sending additional metadata to the server in the same post. For this I hook on to the on submit event and set the value of a hidden field with the data using javascript.  
All this works perfectly fine and on the server I can see the metadata and also the uploaded files in PHP.

But now I need something different. I want to send the data first to the server and then then file upload. So is there some way I can send the metadata first and then trigger the file upload submit?  
I am doing this is that just in case the client upload large files and the upload fails I may not get the important metadata.

---

<div class="post-metadata">

### Author: ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)
#### Post date: [April 23, 2017, 6:38pm UTC](https://forum.kirupa.com/t/how-to-send-2-requests-in-html-javascript/636484/2 "2017-04-23T18:38:48Z")

</div>

I have never tried this, but I noticed somebody asked something similar on the old forums: [https://www.kirupa.com/forum/showthread.php?348289-sending-two-post-requests](https://www.kirupa.com/forum/showthread.php?348289-sending-two-post-requests)

I am not too familiar with PHP anymore, so my default idea is to try sending the metadata post-request using JavaScript. Would that be something you’d want to try?
