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?
Try using :
$().getScript( url, function(data, textStatus){
if (typeof(data) === "object"){
eval(data); //i.e if you're planning to execute your script
}
});
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).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.