Reputation: 684
My problem is that when I try to submit a form with jQuery Form plugin (http://jquery.malsup.com/form/), with contentType: script
, I get "Save as" pop-up on IEs, that tries to save my response script.
Example code:
$("#vendor_edit").ajaxForm({dataType: "script"});
Response is JavaScript, that is properly executed on all the other browsers, but IE tries to save this file "vendors.js". Any idea, what might force IE to trigger this pop-up?
Upvotes: 1
Views: 1355
Reputation: 684
Now that was tricky. Response type matters indeed, it needed to be "text/plain" to stop triggering Save As dialog, instead of "application/javascript" for Explorer.
Also, I had to wrap script "textarea" tag, exclusivelly for Explorer to make eval(response) work for some crazy reazon. All other browsers can handle it without texterea wrapper, but IE has a problem with that (I have seen this solution used by Dojo and copied it).
Upvotes: 0
Reputation: 23114
Try using :
$().getScript( url, function(data, textStatus){
if (typeof(data) === "object"){
eval(data); //i.e if you're planning to execute your script
}
});
Upvotes: 0