[jQuery] jQuery AJAX Dynamic File Download

2008-03-05 Thread Travis Fisher

I've got an export functionality built into my site, whereby users can
choose which rows of a data table to export. They export by clicking
an Actions dropdown and choosing Export. This triggers an AJAX
call that posts which ids to export to a PHP script, which, in turn,
builds an Excel document on the fly and delivers it to the user.

Here is my code:

input type=checkbox id=selected1 name=Interviews[] value=21 /

input type=checkbox id=selected2 name=Interviews[] value=22 /

...

inputs = [];

$(#dataTableBody input[id^=selected]:checked).each(function() {
inputs.push(this.name + '=' + escape(this.value));
});

$.ajax({
type: POST,
data: inputs.join(''),
url: /gateway/excel.php,
success: function(){
return true;
},
error: function(XMLHttpRequest, textStatus, errorThrown){
return false;
}
});

In Firebug, I'm getting the data in TSV format, but I'm not being
presented the download dialog within my browser. If this was a
straight file download, I would link directly to it, but the file has
to be built dynamically. Can I set the dataType option in the ajax
call to be file or something? What are my options?


[jQuery] Re: What is the easiest way to add events to dynamically added rows?

2008-02-21 Thread Travis Fisher

Dan,

I am planning on taking a look at Listen, but I was wondering if the
Delegate plugin has the same functionality as Listen. The reason I'm
inquiring about Delegate is because I am using the Validation plugin,
which requires Delegate.

Thanks for your help.

Travis

On Feb 20, 2:38 pm, Dan G. Switzer, II [EMAIL PROTECTED]
wrote:
 I am dynamically removing and adding rows using AJAX calls.

 Is it still a better idea to go with Listen?

 IMO, yes. You won't have the polling overhead like you do with LiveQuery.
 The $.Listen() plug-in only attaches itself once and then just listens for
 matching key events on it's children to see if it should trigger off a
 callback.

 IMO this is much cleaner solution and it's less likely to introduce any kind
 of memory leaks (since there's only one event ever attached.)

 -Dan