0
我一直在做一些搜索,並試圖找出如何建立一個請求通過的東西送樣建立在JavaScript/jQuery的一個多/表單數據請求
$.ajax({
contentType: "multipart/form-data",
type: "POST",
data: data,
url: url,
success: function (data) { }
});
現在請求本身應該看像這樣的地方是一個JSON作業部分,然後JSON細節部分,以及相關的文件
Content-Type: multipart/form-data; boundary=4fed9b4a-7aae-430f-b907-cbefe7e22c55
--4fed9b4a-7aae-430f-b907-cbefe7e22c55
Content-Type: application/vnd.collection+json
Content-Disposition: form-data; name=job
{json}
--4fed9b4a-7aae-430f-b907-cbefe7e22c55
Content-Type: application/vnd.collection+json
Content-Disposition: form-data; name=details
{json}
--4fed9b4a-7aae-430f-b907-cbefe7e22c55
Content-Type: application/pdf
Content-Disposition: form-data; filename=moo.pdf
xxxxxxxxxxxxxxxxx
--4fed9b4a-7aae-430f-b907-cbefe7e22c55
Content-Type: application/vnd.collection+json
Content-Disposition: form-data; name=details
{json}
--4fed9b4a-7aae-430f-b907-cbefe7e22c55
Content-Type: application/pdf
Content-Disposition: form-data; filename=doh.pdf
xxxxxxxxxxxxxxxxxxxxxxxxxxx
--4fed9b4a-7aae-430f-b907-cbefe7e22c55--
因此,使用Javscript假設我有一個文件數據和JSON數據如何將我構建我可以發送一個請求上面的ajax調用?謝謝
我不知道你會用jQuery來做到這一點。如果是我,我可能會花一些看看這個:https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest – dudeman 2015-03-13 18:25:14
我也會探索這個選項,謝謝! – 2015-03-13 18:52:55