I'm working in a Phonegap project with Restfull Web Services and I need to obtain a PDF file by one of them. I can obtain response using Ajax but I don't know how to work with multipart response. If I read response as always and write a .pdf file with info between "%PDF-1.4" and "EOF", the result file it's a white PDF without information.
I had tried mpAjax project like this:
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');
}
});
But no alert was thrown.
Response example:
--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
Any idea?