在jQuery中解析多部分/混合响应 [英] Parsing multipart/mixed responses in jQuery

查看:97
本文介绍了在jQuery中解析多部分/混合响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

美好的一天.

我是jQuery的新手,并且对javascript有一定的了解,我将大部分时间都花在了服务器端.

I'm new to jQuery, and have a passing familiarity with javascript, having spent most of my time on the server side.

我的兴趣是在浏览器中发布由一个文本字段和一个文件组成的multipart/form-data表单对象.作为响应,服务器返回一个多部分/混合的响应,其中包括一部分html或json,以及一部分应用程序/八位位组流.

My interest is in posting in the browser a multipart/form-data form object consisting of one text field and one file. In response, the server returns a multipart/mixed response consisting of one part html or json, and one part application/octet-stream.

我的目标是学习如何使用jQuery提取html或json部分并有选择地将其显示在目标div中(如果是html)或重定向到json中的URL(如果是json),并将八位字节流保存到磁盘.最好按此顺序.

My goal is to learn how to extract with jQuery the html or json part and optionally display it in a target div (if html) or redirect to a URL in the json (if json), and save the octet-stream to disk. Preferably in that order.

有人会友善地评论一下这种多部分/混合响应解析是否可以用jQuery以及如何做到这一点的想法.

Would someone be kind enough to comment on whether such multipart/mixed response parsing is possible with jQuery and some idea of how to do this.

实际上,尽管我更喜欢jQuery,但我将从任何流行的javascript框架甚至是未经修饰的javascript本身的答案中学到一些东西.

Actually, while I much prefer jQuery, I'll learn something from answers framed in any popular javascript framework, and even unadorned javascript itself.

谢谢.

推荐答案

GREAT问题.从是否存在此插件im来判断:

GREAT question. Judging by the existence of this plugin im assuming no:

我在有关该插件的讨论中也找到了此链接,这可能对您有帮助:

I also found this link in a discussion of that plugin, which might be helpful to you:

http://about.digg.com/blog/duistream-and-mxhr

这篇关于在jQuery中解析多部分/混合响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆