JavaScript How to force file download upon jQuery AJAX success? force file download php,force file download html,force file

I'm generating a file dynamically in php like this :

$attachment_url = "http://www.mysite.com/file.jpg";
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private',false);
header('Content-Type: application/force-download');
header('Content-Disposition: attachment; filename="'.basename( $attachment_url ).'"');
header('Content-Transfer-Encoding: binary');
header('Connection: close');
readfile( $attachment_url );

This data in then passed through jQuery.ajax

I'd like to make it open a file download dialog upon success.

Right now I have this :

success: function(data, textStatus, XMLHttpRequest) {
    var win = window.open();
    win.document.write(data);
}

This does open a new window and display the raw file data. Instead I would like a download dialog to open.

Answer:1

I have a user control having a hidden field that gets set on the node click of a Tree View Hierarchy control. The underlying function for the click event of the Tree View is: function OnTreeClick(evt)...

I have a user control having a hidden field that gets set on the node click of a Tree View Hierarchy control. The underlying function for the click event of the Tree View is: function OnTreeClick(evt)...

  1. hidden field values javascript
  2. hidden field values
  3. hidden field multiple values
  4. clear hidden field values
  5. form hidden field value
  6. jotform clear hidden field values
  7. javascript get hidden field values
  8. how to get hidden field values in jquery
  9. html hidden field multiple values
  10. html hidden field assign values
  11. hidden_field_tag value
  12. rails hidden_field value

I'm trying to get the sum of all div's width on the page and show it on click in alert The problem I'm facing is when I click on the button again to show the sum the result return double and if I ...

I'm trying to get the sum of all div's width on the page and show it on click in alert The problem I'm facing is when I click on the button again to show the sum the result return double and if I ...

  1. diverticulitis
  2. divergent
  3. dividend
  4. diverticulosis
  5. diva cup
  6. divinity
  7. diversity
  8. divalproex
  9. division 2
  10. divine
  11. divorce
  12. divinity original sin 2
  13. dividend stocks
  14. dividing fractions
  15. dive bar
  16. divergent series
  17. diva
  18. diverticulitis diet
  19. divergent cast
  20. divine mercy chaplet

I want to trigger a blur within a keypress. IE10 works differently from Chrome/FF. It appears that IE will finish the keydown handler before calling the blur handler, whereas Chrome and FF will ...

I want to trigger a blur within a keypress. IE10 works differently from Chrome/FF. It appears that IE will finish the keydown handler before calling the blur handler, whereas Chrome and FF will ...

  1. trigger event from parent to child angular
  2. trigger event from business rule servicenow
  3. trigger event from workflow servicenow
  4. trigger event from parent to child react
  5. trigger event from javascript
  6. trigger event from iframe to parent
  7. trigger event from ui action servicenow
  8. trigger event from client script servicenow
  9. trigger event from another class c#
  10. trigger event from iframe
  11. trigger event from js
  12. trigger event from jquery
  13. trigger event from script servicenow
  14. trigger event from parent vue
  15. trigger event from mongodb
  16. trigger event from xaml
  17. trigger event from php
  18. trigger event from java
  19. trigger from event
  20. trigger event on element

i have a html page in which i have a number of anchor tags i want to add rel="no follow" attribute in anchor tag if it doesn't have it on the pages whose source is starting with hyper text transfer ...

i have a html page in which i have a number of anchor tags i want to add rel="no follow" attribute in anchor tag if it doesn't have it on the pages whose source is starting with hyper text transfer ...