-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathajax-request-blob-content.html
92 lines (77 loc) · 4.28 KB
/
ajax-request-blob-content.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<!DOCTYPE html>
<html lang="en">
<head>
<!-- ## for client-side less
<link rel="stylesheet/less" type="text/css" href="http://thierry.ducrest.net/theme/css/style.less">
<script src="http://cdnjs.cloudflare.com/ajax/libs/less.js/1.7.3/less.min.js" type="text/javascript"></script>
-->
<link rel="stylesheet" href="http://thierry.ducrest.net/theme/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="http://thierry.ducrest.net/theme/css/style.css">
<link rel="stylesheet" type="text/css" href="http://thierry.ducrest.net/theme/css/pygments.css">
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=PT+Sans|PT+Serif|PT+Mono">
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="Thierry Ducrest">
<meta name="description" content="Posts and writings by Thierry Ducrest">
<link href="http://feeds.thierry.ducrest.net/feeds/all.atom.xml" type="application/atom+xml" rel="alternate" title=" Atom" />
<meta name="keywords" content="Web, HTTP">
<title>
– Ajax request and blob content </title>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-41998474-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<aside>
<div id="user_meta">
<a href="http://thierry.ducrest.net">
<img src="http://thierry.ducrest.net/theme/images/empty.png" alt="logo">
</a>
<h2><a href="http://thierry.ducrest.net">Thierry Ducrest</a></h2>
<p>Software Developer</p>
<ul>
<li><a href="https://github.com/TDu" target="_blank"><i class="fa fa-github fa-lg"></i></a></li>
<li><a href="https://cl.linkedin.com/in/thierry-ducrest-928a394" target="_blank"><i class="fa fa-linkedin-square fa-lg"></i></a></li>
<li><a href="https://twitter.com/thducrest" target="_blank"><i class="fa fa-twitter fa-lg"></i></a></li>
</ul>
</div>
</aside>
<main>
<header>
<p>
<a href="http://thierry.ducrest.net">Index</a> ¦ <a href="http://thierry.ducrest.net/archives.html">Archives</a>
¦ <a href="http://feeds.thierry.ducrest.net/feeds/all.atom.xml">Atom</a>
</p>
</header>
<article>
<h3><a href="http://thierry.ducrest.net/ajax-request-blob-content.html">Ajax request and blob content</a></h3>
<span class="date-article">06 September 2016</span>
<div class="article_text">
<p>The web app I am building as a separate nodejs service than run for the sole purpose of generating pdf files for various content. That service does not have access to the database content but receive on each request the data that needs to be printed. And send back the binary data corresponding of the pdf file generated that will be offered to download to the user.</p>
<p>The first version used a GET request but there is a limit with the length of the data that can be passed this way. The limit (between 2kb-5kb) varies from browser and server type and it is recommended not to use this method above 255 bytes.</p>
<p>The switch to a POST request was not that straight forward, I could not understand why the pdf received by the client were always badly formed and unreadable. Turns out that the jquery ajax method does not support the blob format.</p>
<p>This is <a href="https://bugs.jquery.com/ticket/7248">the bug</a> marked as won't fix</p>
<p>All for the best it made me switch to XMLHttpRequest.</p>
</div>
<div class="article_meta">
<p>Posted on: Tue 06 September 2016</p>
<p>Category: <a href="http://thierry.ducrest.net/category/misc.html">misc</a>
– Tags:
<a href="http://thierry.ducrest.net/tag/web.html">Web</a>, <a href="http://thierry.ducrest.net/tag/http.html">HTTP</a> </p>
</div>
</article>
<div id="ending_message">
<!--
<p>© Thierry Ducrest. Built using <a href="http://getpelican.com" target="_blank">Pelican</a>.</p>
-->
</div>
</main>
</body>
</html>