I have been using this function I found a long time ago to do downloads - I want to modify it to pass a large JSON string to the download.aspx page. With that said I am trying to first understand it and I am confused...
And I have been calling it like thisCode:$.download = function(url, data, method, callback){ var inputs = ''; var iframeX; var downloadInterval; if(url && data){ // remove old iframe if has if($("#iframeX")) $("#iframeX").remove(); // creater new iframe iframeX= $('<iframe src="[removed]false;" name="iframeX" id="iframeX"></iframe>').appendTo('body').hide(); if($.browser.msie){ downloadInterval = setInterval(function(){ // if loading then readyState is “loading” else readyState is “interactive” if(iframeX&& iframeX[0].readyState !=="loading"){ callback(); clearInterval(downloadInterval); } }, 23); } else { iframeX.load(function(){ callback(); }); } //split params into form inputs var inputs = ''; jQuery.each(data.split('&'), function() { var pair = this.split('='); inputs += '<input type="hidden" name="' + pair[0] + '" value="' + pair[1] + '" />'; }); //create form to send request $('<form action="'+ url +'" method="'+ (method||'post') + '" target="iframeX">'+inputs+'</form>').appendTo('body').submit().remove(); }; };
Note that I am only passing in two parameters to this function. That means that "callback" parameter is not defined within the function.Code:function downloadrpt(rptid) { $.download('Download.aspx', 'rptid=' + rptid + '&user=' + window.username); } function downloadfile(filename) { $.download('Download.aspx', 'fn=' + filename + '&user=' + window.username); }
In that $.download function there is a iframeX.Load() call that I don't understand. I looked around and the jQuery .Load method doesn't seem to take a function as a parameter - and that callback() function is not even being passed in.
What is that supposed to be doing???Code:iframeX.load(function(){ callback(); });


Reply With Quote
