Welcome Guest, Not a member yet? Register   Sign In
Problem with download helper and AJAX calls. Expertise needed.
#8

[eluser]gRoberts[/eluser]
Sorry, just noticed a little error in my code above:

Code:
(function()
{
  $('#download').click(function(e)
  {
   e.preventDefault();
   $.ajax(
   {
    url : 'controller/action',
    dataType : 'json',
    type : 'POST',
    data :
    {
     Image1 : 'friend.jpg',
     Image2 : 'dog.jpg'
    },
    success : function(resp)
    {
     // using the iframe method
     if($('.download-frame').length == 0)
     {
      $('body').append($('<iframe class="download-frame" src="about:blank" />').css({ width : 1, height : 1 }));
     }
     $('.download-frame').attr('src', resp.DownloadPath);

     // using the [removed].href method
     [removed].href = resp.DownloadPath;
    },
    error : function()
    {
     alert('There was a problem generating the ZIP');
    }
   });
  });
});

With the #1 Iframe method, it would only work if the iframe did not exist due to an incorrectly place line of code.

I have moved the `$('.download-frame').attr('src', resp.DownloadPath);` outside of the if statement.


Messages In This Thread
Problem with download helper and AJAX calls. Expertise needed. - by El Forum - 05-17-2012, 11:12 PM



Theme © iAndrew 2016 - Forum software by © MyBB