0

i have done application using Extjs, here requirement is need to download file from server also need to showcase loadmask untill file is completely download. Here i am generating dynamic pdf url by appending name to server base URL. some time in server don't have pdf file for particular url(name) may be they will add or delete the pdf files for some names, but i am assigning generated pdf url based on selected name to ifrmae as a source path. if the pdf is not found in server that time iframe is shows a page, like 404 server not found etc... instead of this one i need to showcase alert message pdf file is not available for this particular name. Can anybody tell me How to achieve this one? great appreciated. Thank you.

Here is my code:

getPdfDataIniFrame: function(vesselName){
        var strVesselName=vesselName;
        vesselSpecificationName=strVesselName.replace(" ","_");
        speficationUrl="http://BaseUrl/"+vesselSpecificationName+".pdf"  
Ext.getCmp('pnlPdf').update('<iframe id="iframeId" width="100%" height="85%" frameborder="0" scrolling="no" src="'+speficationUrl+'"></iframe>')
} 
Ramesh Lamani
  • 1,117
  • 3
  • 25
  • 54

1 Answers1

0

Why cant you try with ajax implementation. i feel the plm may be bind of request with iframe and update to component. try with below one. it may help!!

Ext.Ajax.request({
    url: <url>,
    method: 'POST',
    headers: {
        'Content-type': 'application/json', 
        'Accept': 'application/pdf'
    },
    success: function(response){

    },
    failure: function(response){

    }
});

Accept: application/pdf is most important.

Thanks

Hariharan
  • 3,191
  • 4
  • 19
  • 31
  • Hi, Thank you for your reply. I have tried as above but it is giving error in console like this. XMLHttpRequest cannot load http://BaseUrlofServer/Sea_Kiowa.pdf. Origin file:// is not allowed by Access-Control-Allow-Origin. How to resolve this issue? Thank you – Ramesh Lamani May 23 '13 at 13:03
  • check response header in browser debug tool (Developer tool or firebug). – Hariharan May 23 '13 at 13:18
  • I am getting..from failed response like this. getAllResponseHeaders: function () { arguments: null caller: null length: 0 name: "" prototype: Object __proto__: function () { getResponseHeader: function (header) { arguments: null caller: null length: 1 name: "" prototype: Object __proto__: function () { request: Object async: true headers: Object id: 1 options: Object __proto__: Object requestId: 1 responseText: "" responseXML: null status: 0 statusText: "" __proto__: Object – Ramesh Lamani May 23 '13 at 13:54