Server cannot set content type after HTTP headers have been sent

Hi All,

I was getting an error when I'm trying to download a file from the link with ajax submit.

The server cannot set content type after HTTP headers have been sent

I think we should only use submit instead of ajax submit to download and upload a file but unfortunately I must use ajax submit for multiple reasons.

However, I thought I can use a hidden link and call click function through Runjavascript server action on Ajax submit action so that I can click the link dynamically which contains submit action and that very screen action can download my file but no luck even though i'm running runjavascript action on main action its not triggering the hidden link action :(

What am i missing over here?

Thanks in advanvce


Gandeev b wrote:

Hi All,

I was getting an error when I'm trying to download a file from the link with ajax submit.

The server cannot set content type after HTTP headers have been sent

I think we should only use submit instead of ajax submit to download and upload a file but unfortunately I must use ajax submit for multiple reasons.

However, I thought I can use a hidden link and call click function through Runjavascript server action on Ajax submit action so that I can click the link dynamically which contains submit action and that very screen action can download my file but no luck even though i'm running runjavascript action on main action its not triggering the hidden link action :(

What am i missing over here?

Thanks in advanvce


Hello Gandeev,


Can you please attach the oml to look for your code and see what is wrong?

How are you calling the hidden link? By Id?

Thanks 


Luís Cardoso wrote:

Gandeev b wrote:

Hi All,

I was getting an error when I'm trying to download a file from the link with ajax submit.

The server cannot set content type after HTTP headers have been sent

I think we should only use submit instead of ajax submit to download and upload a file but unfortunately I must use ajax submit for multiple reasons.

However, I thought I can use a hidden link and call click function through Runjavascript server action on Ajax submit action so that I can click the link dynamically which contains submit action and that very screen action can download my file but no luck even though i'm running runjavascript action on main action its not triggering the hidden link action :(

What am i missing over here?

Thanks in advanvce


Hello Gandeev,


Can you please attach the oml to look for your code and see what is wrong?

How are you calling the hidden link? By Id?

Thanks 


Hi Luis,

"$('#" + DownloadLink.Id + "').click();"

also tired with js_click server action with runjavascript but it didnt work


Hi Gandeev,


You should have to use submit method to download file and end the of action need to use.

and in this submit method your page will not load only content will download.


as a link


and content will not able to download by client action from Server.

also u can use widget click insted of js.

and which button you used is hidden only by style not server side like display:none not set to visible false



Hope this will help you.


Thanks

Rahul Sahu

And how did you hide the link? 

Luís Cardoso wrote:

And how did you hide the link? 

i have used Style="display:none;"


Rahul Sahu wrote:

Hi Gandeev,


You should have to use submit method to download file and end the of action need to use.

and in this submit method your page will not load only content will download.


as a link


and content will not able to download by client action from Server.

also u can use widget click insted of js.

and which button you used is hidden only by style not server side like display:none not set to visible false



Hope this will help you.


Thanks

Rahul Sahu

Hi Rahul ,


Thank for your input i even using Widget_Click server action  but still it didnt work 

I didnt get what you actually meant by which button you used is hidden only by style not server side like display:none not set to visible false

However i was using style=diplay:none; extended property 


Gandeev b wrote:

Luís Cardoso wrote:

And how did you hide the link? 

i have used Style="display:none;"


It looks fine. Can you please upload the oml file? Thanks 


Luís Cardoso wrote:

Gandeev b wrote:

Luís Cardoso wrote:

And how did you hide the link? 

i have used Style="display:none;"


It looks fine. Can you please upload the oml file? Thanks 


Hi Luis,

I created very basic replica and attaching the same


Gandeev b wrote:

Luís Cardoso wrote:

Gandeev b wrote:

Luís Cardoso wrote:

And how did you hide the link? 

i have used Style="display:none;"


It looks fine. Can you please upload the oml file? Thanks 


Hi Luis,

I created very basic replica and attaching the same


Ok thank. I will give a look and provide you feedback 


Hi Gandeev,

SyntaxEditor Code Snippet

"$('#"+AutoClick.Id+"')[0].click();"

Try this instead of your js.

its working.

Gandeev,


If you use a button instead of a link your code is correct. If you use a link like your example you need to do lik Rahul Sahu said.


Please see attachment OML with other solution, I call the js in the link with property onclick and works.