function DownLoadPost(url,data) { if (url && data) { var form = $('<form>{{ xsrf_form_html()|safe }}</form>'); form.attr('action', url + "?rand=" + Math.random()); form.attr('method', 'post'); for (var item in data) { console.log(data[item]); var input = $('<input type="text" />'); input.attr('name', item); input.attr('value', data[item]); form.append(input); } console.log(form.html()); form.appendTo('body').submit().remove(); }; }