Skip to content

Commit 9b77aca

Browse files
committed
Ajax: fix parsing response Content-Type from the server
Fixes #699
1 parent 3771d17 commit 9b77aca

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

src/ajax.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@
148148
}
149149

150150
function mimeToDataType(mime) {
151+
if (mime) mime = mime.split(';', 2)[0]
151152
return mime && ( mime == htmlType ? 'html' :
152153
mime == jsonType ? 'json' :
153154
scriptTypeRE.test(mime) ? 'script' :

test/ajax.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,19 @@ <h1>Zepto Ajax unit tests</h1>
252252
$.ajax({ url: 'echo' })
253253
},
254254

255+
testAjaxJSON: function(t){
256+
t.pause()
257+
resumeOnAjaxError(t)
258+
259+
$.ajax({
260+
url: 'json',
261+
headers: { accept: 'application/json' },
262+
success: t.reg.resumeHandler('success', function(data){
263+
t.assertEqual('world', data.hello)
264+
})
265+
})
266+
},
267+
255268
testAjaxGetJSON: function(t){
256269
t.pause()
257270
resumeOnAjaxError(t)

0 commit comments

Comments
 (0)