我正在使用Restfull Web Services处理Phonegap项目,我需要通过其中一个获取PDF文件。我可以使用Ajax获取响应,但我不知道如何使用多部分响应。如果我一如既往地读取响应并编写一个包含“%PDF-1.4”和“EOF”之间信息的.pdf文件,那么结果文件就是一张没有信息的白色PDF。
我曾尝试过像这样的mpAjax项目:
jQuery.ajax({
async: false,
url: urlWS,
data: info,
contentType:'application/json;charset=UTF-8',
type: 'post',
success:{
"application/json": function (response) {alert('info: ');},
"application/pdf":callback_handleData
},
error: function (xhr, ajaxOptions, thrownError) {
alert('AJAX ERROR');
}
});
但没有引发警报。
回应示例:
--uuid:7c26de68-83e9-456a-a986-65dfa8e74d88
Content-Type: application/json;charset=UTF-8
Content-Transfer-Encoding: binary
Content-ID: <ROOT>
{"attachedContenId":"DOC","document":{"docName":"38522672H ","mimeType":"application/pdf","itemType":"FACTURASSIC","nodeId":"cm://FACTURASSIC/ITEMID:A1001001A13G04A93633J51684","size":1120990},"props":[{"atribute":"IDCLIENTE","value":"38522672H "},{"atribute":"NUMPOL","value":"000413SC "},{"atribute":"NUMFACTURASIC","value":"AB20130622824"},{"atribute":"FECHA","value":"2013-01-25"},{"atribute":"ENTIDAD","value":"2013 "},{"atribute":"APARTADO","value":"0056"},{"atribute":"FECHAFACT","value":"2013-01-16"},{"atribute":"TIPODOC","value":"FACTURA1CA_12031"}],"error":""}
--uuid:7c26de68-83e9-456a-a986-65dfa8e74d88
Content-Type: application/pdf
Content-Transfer-Encoding: binary
Content-ID: <DOC>
%PDF-1.4
%����
3 0 obj
<</Length 25
有什么想法吗?