内容类型为HTML片段 [英] Content type for HTML fragments

查看:154
本文介绍了内容类型为HTML片段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个服务器发送与体内的HTML文档的HTTP响应,它通常会使用的text / html 的内容类型。如果内容类型是不同的,如果效应初探是HTML片段?

When a server sends an HTTP response with an HTML document in the body, it would usually use the text/html content type. Should the content type be different if the reponse is a fragment of HTML?

例如,如果请求是AJAX从客户端脚本和整个响应的身体< D​​IV>< P>新建文字< / P>< / DIV> 那么响应不是HTML文档。如果应用程序设置的内容类型以外的其他的text / html 这样的片段?如果有,是什么?

For example, if the request is AJAX from a client script and the entire response body is <div><p>New text</p></div> then the response is not an HTML document. Should the application set the content type to something other than text/html for such fragments? If so, what?

推荐答案

这是一个个人的preference。如果只是你的应用程序,那么也没关系。我想保持它的text / html ,因为它仍然是HTML标记,即使不是一个完整的文档。

It's a personal preference. If it is only your app, then it doesn't matter. I would keep it text/html because it is still HTML markup, even if not a complete document.

这篇关于内容类型为HTML片段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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