{"id":75,"date":"2014-02-07T16:24:47","date_gmt":"2014-02-07T16:24:47","guid":{"rendered":"http:\/\/www.tvarwebu.cz\/blog\/?p=75"},"modified":"2014-02-07T16:34:49","modified_gmt":"2014-02-07T16:34:49","slug":"updated-script-for-downloading-file-via-ajax","status":"publish","type":"post","link":"https:\/\/www.tvarwebu.cz\/blog\/2014\/02\/updated-script-for-downloading-file-via-ajax\/","title":{"rendered":"Updated script for downloading file from javascript"},"content":{"rendered":"<p>I had to use the ajax to download a file internally on our <a title=\"forms mobile app for managing custom qustionaire\" href=\"https:\/\/www.nestforms.com\/\">NestForms<\/a> project. I was searching for a solution and found one on <a href=\"http:\/\/www.filamentgroup.com\/lab\/jquery_plugin_for_requesting_ajax_like_file_downloads\/\">Filamentgroup<\/a> website.<\/p>\n<p>Unforutunatelly, there were some issues that it did not correctly encoded the request. So I had to update the script in order to make it working. See the code below. I hope that it will help you solve your problems.<\/p>\n<pre lang=\"javascript\">jQuery.download = function(url, data, method){\r\n  \/\/url and data options required\r\n  if( url &amp;&amp; data ){\r\n    \/\/data can be string of parameters or array\/object\r\n    data = typeof data == 'string' ? data : jQuery.param(data);\r\n    \/\/split params into form inputs\r\n    var inputs = new Array();\r\n    jQuery.each(data.split('&amp;'), function(){\r\n      var pair = this.split('=');\r\n      inputs[inputs.length] = $('&lt;input name=\"'+ decodeURIComponent(pair[0]) +'\" type=\"hidden\" \/&gt;')\r\n        .val(decodeURIComponent( pair[1].replace(\/\\+\/g, \" \")));\r\n    });\r\n    \/\/send request\r\n    jQuery('&lt;form action=\"'+ url +'\" method=\"'+ (method||'post') +'\"&gt;'+'&lt;\/form&gt;').append(inputs)\r\n    .appendTo('body').submit().remove();\r\n  };\r\n};<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I had to use the ajax to download a file internally on our NestForms project. I was searching for a solution and found one on Filamentgroup website. Unforutunatelly, there were some issues that it did not correctly encoded the request. So I had to update the script in order to make it working. See the &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"https:\/\/www.tvarwebu.cz\/blog\/2014\/02\/updated-script-for-downloading-file-via-ajax\/\">Continue reading<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-75","post","type-post","status-publish","format-standard","hentry","category-uncategorized","item-wrap"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 4.9.8 - aioseo.com -->\n\t<meta name=\"description\" content=\"I had to use the ajax to download a file internally on our NestForms project. I was searching for a solution and found one on Filamentgroup website. Unforutunatelly, there were some issues that it did not correctly encoded the request. So I had to update the script in order to make it working. See the\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Ond\u0159ej\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/www.tvarwebu.cz\/blog\/2014\/02\/updated-script-for-downloading-file-via-ajax\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 4.9.8\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Tv\u00e1\u0159 Webu Blog | Blog about webdesign, web, adroid and iphone development\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Updated script for downloading file from javascript | Tv\u00e1\u0159 Webu Blog\" \/>\n\t\t<meta property=\"og:description\" content=\"I had to use the ajax to download a file internally on our NestForms project. I was searching for a solution and found one on Filamentgroup website. Unforutunatelly, there were some issues that it did not correctly encoded the request. So I had to update the script in order to make it working. See the\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/www.tvarwebu.cz\/blog\/2014\/02\/updated-script-for-downloading-file-via-ajax\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2014-02-07T16:24:47+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2014-02-07T16:34:49+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Updated script for downloading file from javascript | Tv\u00e1\u0159 Webu Blog\" \/>\n\t\t<meta name=\"twitter:description\" content=\"I had to use the ajax to download a file internally on our NestForms project. I was searching for a solution and found one on Filamentgroup website. Unforutunatelly, there were some issues that it did not correctly encoded the request. So I had to update the script in order to make it working. See the\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.tvarwebu.cz\\\/blog\\\/2014\\\/02\\\/updated-script-for-downloading-file-via-ajax\\\/#article\",\"name\":\"Updated script for downloading file from javascript | Tv\\u00e1\\u0159 Webu Blog\",\"headline\":\"Updated script for downloading file from javascript\",\"author\":{\"@id\":\"https:\\\/\\\/www.tvarwebu.cz\\\/blog\\\/author\\\/twadmin\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.tvarwebu.cz\\\/blog\\\/#organization\"},\"datePublished\":\"2014-02-07T16:24:47+00:00\",\"dateModified\":\"2014-02-07T16:34:49+00:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.tvarwebu.cz\\\/blog\\\/2014\\\/02\\\/updated-script-for-downloading-file-via-ajax\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tvarwebu.cz\\\/blog\\\/2014\\\/02\\\/updated-script-for-downloading-file-via-ajax\\\/#webpage\"},\"articleSection\":\"Uncategorized\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.tvarwebu.cz\\\/blog\\\/2014\\\/02\\\/updated-script-for-downloading-file-via-ajax\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tvarwebu.cz\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.tvarwebu.cz\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tvarwebu.cz\\\/blog\\\/category\\\/uncategorized\\\/#listItem\",\"name\":\"Uncategorized\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tvarwebu.cz\\\/blog\\\/category\\\/uncategorized\\\/#listItem\",\"position\":2,\"name\":\"Uncategorized\",\"item\":\"https:\\\/\\\/www.tvarwebu.cz\\\/blog\\\/category\\\/uncategorized\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tvarwebu.cz\\\/blog\\\/2014\\\/02\\\/updated-script-for-downloading-file-via-ajax\\\/#listItem\",\"name\":\"Updated script for downloading file from javascript\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tvarwebu.cz\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tvarwebu.cz\\\/blog\\\/2014\\\/02\\\/updated-script-for-downloading-file-via-ajax\\\/#listItem\",\"position\":3,\"name\":\"Updated script for downloading file from javascript\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tvarwebu.cz\\\/blog\\\/category\\\/uncategorized\\\/#listItem\",\"name\":\"Uncategorized\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.tvarwebu.cz\\\/blog\\\/#organization\",\"name\":\"Tv\\u00e1\\u0159 Webu Blog\",\"description\":\"Blog about webdesign, web, adroid and iphone development\",\"url\":\"https:\\\/\\\/www.tvarwebu.cz\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.tvarwebu.cz\\\/blog\\\/author\\\/twadmin\\\/#author\",\"url\":\"https:\\\/\\\/www.tvarwebu.cz\\\/blog\\\/author\\\/twadmin\\\/\",\"name\":\"Ond\\u0159ej\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.tvarwebu.cz\\\/blog\\\/2014\\\/02\\\/updated-script-for-downloading-file-via-ajax\\\/#webpage\",\"url\":\"https:\\\/\\\/www.tvarwebu.cz\\\/blog\\\/2014\\\/02\\\/updated-script-for-downloading-file-via-ajax\\\/\",\"name\":\"Updated script for downloading file from javascript | Tv\\u00e1\\u0159 Webu Blog\",\"description\":\"I had to use the ajax to download a file internally on our NestForms project. I was searching for a solution and found one on Filamentgroup website. Unforutunatelly, there were some issues that it did not correctly encoded the request. So I had to update the script in order to make it working. See the\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tvarwebu.cz\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.tvarwebu.cz\\\/blog\\\/2014\\\/02\\\/updated-script-for-downloading-file-via-ajax\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.tvarwebu.cz\\\/blog\\\/author\\\/twadmin\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.tvarwebu.cz\\\/blog\\\/author\\\/twadmin\\\/#author\"},\"datePublished\":\"2014-02-07T16:24:47+00:00\",\"dateModified\":\"2014-02-07T16:34:49+00:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.tvarwebu.cz\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.tvarwebu.cz\\\/blog\\\/\",\"name\":\"Tv\\u00e1\\u0159 Webu Blog\",\"description\":\"Blog about webdesign, web, adroid and iphone development\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.tvarwebu.cz\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Updated script for downloading file from javascript | Tv\u00e1\u0159 Webu Blog","description":"I had to use the ajax to download a file internally on our NestForms project. I was searching for a solution and found one on Filamentgroup website. Unforutunatelly, there were some issues that it did not correctly encoded the request. So I had to update the script in order to make it working. See the","canonical_url":"https:\/\/www.tvarwebu.cz\/blog\/2014\/02\/updated-script-for-downloading-file-via-ajax\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.tvarwebu.cz\/blog\/2014\/02\/updated-script-for-downloading-file-via-ajax\/#article","name":"Updated script for downloading file from javascript | Tv\u00e1\u0159 Webu Blog","headline":"Updated script for downloading file from javascript","author":{"@id":"https:\/\/www.tvarwebu.cz\/blog\/author\/twadmin\/#author"},"publisher":{"@id":"https:\/\/www.tvarwebu.cz\/blog\/#organization"},"datePublished":"2014-02-07T16:24:47+00:00","dateModified":"2014-02-07T16:34:49+00:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/www.tvarwebu.cz\/blog\/2014\/02\/updated-script-for-downloading-file-via-ajax\/#webpage"},"isPartOf":{"@id":"https:\/\/www.tvarwebu.cz\/blog\/2014\/02\/updated-script-for-downloading-file-via-ajax\/#webpage"},"articleSection":"Uncategorized"},{"@type":"BreadcrumbList","@id":"https:\/\/www.tvarwebu.cz\/blog\/2014\/02\/updated-script-for-downloading-file-via-ajax\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/www.tvarwebu.cz\/blog#listItem","position":1,"name":"Home","item":"https:\/\/www.tvarwebu.cz\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/www.tvarwebu.cz\/blog\/category\/uncategorized\/#listItem","name":"Uncategorized"}},{"@type":"ListItem","@id":"https:\/\/www.tvarwebu.cz\/blog\/category\/uncategorized\/#listItem","position":2,"name":"Uncategorized","item":"https:\/\/www.tvarwebu.cz\/blog\/category\/uncategorized\/","nextItem":{"@type":"ListItem","@id":"https:\/\/www.tvarwebu.cz\/blog\/2014\/02\/updated-script-for-downloading-file-via-ajax\/#listItem","name":"Updated script for downloading file from javascript"},"previousItem":{"@type":"ListItem","@id":"https:\/\/www.tvarwebu.cz\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/www.tvarwebu.cz\/blog\/2014\/02\/updated-script-for-downloading-file-via-ajax\/#listItem","position":3,"name":"Updated script for downloading file from javascript","previousItem":{"@type":"ListItem","@id":"https:\/\/www.tvarwebu.cz\/blog\/category\/uncategorized\/#listItem","name":"Uncategorized"}}]},{"@type":"Organization","@id":"https:\/\/www.tvarwebu.cz\/blog\/#organization","name":"Tv\u00e1\u0159 Webu Blog","description":"Blog about webdesign, web, adroid and iphone development","url":"https:\/\/www.tvarwebu.cz\/blog\/"},{"@type":"Person","@id":"https:\/\/www.tvarwebu.cz\/blog\/author\/twadmin\/#author","url":"https:\/\/www.tvarwebu.cz\/blog\/author\/twadmin\/","name":"Ond\u0159ej"},{"@type":"WebPage","@id":"https:\/\/www.tvarwebu.cz\/blog\/2014\/02\/updated-script-for-downloading-file-via-ajax\/#webpage","url":"https:\/\/www.tvarwebu.cz\/blog\/2014\/02\/updated-script-for-downloading-file-via-ajax\/","name":"Updated script for downloading file from javascript | Tv\u00e1\u0159 Webu Blog","description":"I had to use the ajax to download a file internally on our NestForms project. I was searching for a solution and found one on Filamentgroup website. Unforutunatelly, there were some issues that it did not correctly encoded the request. So I had to update the script in order to make it working. See the","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/www.tvarwebu.cz\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/www.tvarwebu.cz\/blog\/2014\/02\/updated-script-for-downloading-file-via-ajax\/#breadcrumblist"},"author":{"@id":"https:\/\/www.tvarwebu.cz\/blog\/author\/twadmin\/#author"},"creator":{"@id":"https:\/\/www.tvarwebu.cz\/blog\/author\/twadmin\/#author"},"datePublished":"2014-02-07T16:24:47+00:00","dateModified":"2014-02-07T16:34:49+00:00"},{"@type":"WebSite","@id":"https:\/\/www.tvarwebu.cz\/blog\/#website","url":"https:\/\/www.tvarwebu.cz\/blog\/","name":"Tv\u00e1\u0159 Webu Blog","description":"Blog about webdesign, web, adroid and iphone development","inLanguage":"en-US","publisher":{"@id":"https:\/\/www.tvarwebu.cz\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"Tv\u00e1\u0159 Webu Blog | Blog about webdesign, web, adroid and iphone development","og:type":"article","og:title":"Updated script for downloading file from javascript | Tv\u00e1\u0159 Webu Blog","og:description":"I had to use the ajax to download a file internally on our NestForms project. I was searching for a solution and found one on Filamentgroup website. Unforutunatelly, there were some issues that it did not correctly encoded the request. So I had to update the script in order to make it working. See the","og:url":"https:\/\/www.tvarwebu.cz\/blog\/2014\/02\/updated-script-for-downloading-file-via-ajax\/","article:published_time":"2014-02-07T16:24:47+00:00","article:modified_time":"2014-02-07T16:34:49+00:00","twitter:card":"summary_large_image","twitter:title":"Updated script for downloading file from javascript | Tv\u00e1\u0159 Webu Blog","twitter:description":"I had to use the ajax to download a file internally on our NestForms project. I was searching for a solution and found one on Filamentgroup website. Unforutunatelly, there were some issues that it did not correctly encoded the request. So I had to update the script in order to make it working. See the"},"aioseo_meta_data":{"post_id":"75","title":null,"description":null,"keywords":[{"label":"javascript","value":"javascript"},{"label":"file download","value":"file download"}],"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":true,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2025-07-15 07:33:19","updated":"2025-07-15 07:43:22","seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.tvarwebu.cz\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.tvarwebu.cz\/blog\/category\/uncategorized\/\" title=\"Uncategorized\">Uncategorized<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tUpdated script for downloading file from javascript\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/www.tvarwebu.cz\/blog"},{"label":"Uncategorized","link":"https:\/\/www.tvarwebu.cz\/blog\/category\/uncategorized\/"},{"label":"Updated script for downloading file from javascript","link":"https:\/\/www.tvarwebu.cz\/blog\/2014\/02\/updated-script-for-downloading-file-via-ajax\/"}],"_links":{"self":[{"href":"https:\/\/www.tvarwebu.cz\/blog\/wp-json\/wp\/v2\/posts\/75","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tvarwebu.cz\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tvarwebu.cz\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tvarwebu.cz\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tvarwebu.cz\/blog\/wp-json\/wp\/v2\/comments?post=75"}],"version-history":[{"count":14,"href":"https:\/\/www.tvarwebu.cz\/blog\/wp-json\/wp\/v2\/posts\/75\/revisions"}],"predecessor-version":[{"id":89,"href":"https:\/\/www.tvarwebu.cz\/blog\/wp-json\/wp\/v2\/posts\/75\/revisions\/89"}],"wp:attachment":[{"href":"https:\/\/www.tvarwebu.cz\/blog\/wp-json\/wp\/v2\/media?parent=75"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tvarwebu.cz\/blog\/wp-json\/wp\/v2\/categories?post=75"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tvarwebu.cz\/blog\/wp-json\/wp\/v2\/tags?post=75"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}