pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

<small id='As2uE'></small><noframes id='As2uE'>

  • <legend id='As2uE'><style id='As2uE'><dir id='As2uE'><q id='As2uE'></q></dir></style></legend>
    • <bdo id='As2uE'></bdo><ul id='As2uE'></ul>

    1. <i id='As2uE'><tr id='As2uE'><dt id='As2uE'><q id='As2uE'><span id='As2uE'><b id='As2uE'><form id='As2uE'><ins id='As2uE'></ins><ul id='As2uE'></ul><sub id='As2uE'></sub></form><legend id='As2uE'></legend><bdo id='As2uE'><pre id='As2uE'><center id='As2uE'></center></pre></bdo></b><th id='As2uE'></th></span></q></dt></tr></i><div class="vvvnvzb" id='As2uE'><tfoot id='As2uE'></tfoot><dl id='As2uE'><fieldset id='As2uE'></fieldset></dl></div>

        <tfoot id='As2uE'></tfoot>

        瀏覽器對 json ajax 響應的 Content-Type 標頭有什么要

        What do browsers want for the Content-Type header on json ajax responses?(瀏覽器對 json ajax 響應的 Content-Type 標頭有什么要求?)

      1. <small id='Klgpy'></small><noframes id='Klgpy'>

          <bdo id='Klgpy'></bdo><ul id='Klgpy'></ul>
                  <tbody id='Klgpy'></tbody>

                • <i id='Klgpy'><tr id='Klgpy'><dt id='Klgpy'><q id='Klgpy'><span id='Klgpy'><b id='Klgpy'><form id='Klgpy'><ins id='Klgpy'></ins><ul id='Klgpy'></ul><sub id='Klgpy'></sub></form><legend id='Klgpy'></legend><bdo id='Klgpy'><pre id='Klgpy'><center id='Klgpy'></center></pre></bdo></b><th id='Klgpy'></th></span></q></dt></tr></i><div class="bjzlvhb" id='Klgpy'><tfoot id='Klgpy'></tfoot><dl id='Klgpy'><fieldset id='Klgpy'></fieldset></dl></div>
                  <tfoot id='Klgpy'></tfoot>
                  <legend id='Klgpy'><style id='Klgpy'><dir id='Klgpy'><q id='Klgpy'></q></dir></style></legend>
                  本文介紹了瀏覽器對 json ajax 響應的 Content-Type 標頭有什么要求?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在返回一些需要由 javascript 處理的 json 作為對 XMLHTTPRequest 的響應.

                  如果我將響應的內容類型設置為text/plain",除 Chrome 之外的所有瀏覽器都會接受它并將其傳遞給我的 JS,沒有問題.但是,Chrome 會將響應包裝在

                  在將其傳遞給我的 javascript 之前.

                  如果我將響應的內容類型設置為正確"應用程序/json",所有瀏覽器,但 Firefox 將接受它并將其傳遞給我的 JS,沒有問題.但是,Firefox 會要求將響應保存或打開為文件.

                  什么是正確的跨瀏覽器內容類型?

                  解決方案

                  您可以通過使用jQuery funcion parseJSON - http://api.jquery.com/jQuery.parseJSON/

                  您傳遞給函數的參數是 JSON 對象字符串,您從響應數據中提取:

                  function AjaxResponse (data) {//AJAX post 回調var jsonResult = $.parseJSON(data.substring(data.indexOf("{"), data.lastIndexOf("}") + 1));}

                  在 FF 和 IE8 中針對以下簡單 JSON 結果進行了測試(除了 Chrome 解決了哪個問題),對于其他瀏覽器和更復雜的響應,無法保證...

                  <小時>

                  注意:我認為這種情況下的內容類型是 text/plain 或 text/html - 我使用了以下 ASP.Net MVC 函數來返回結果

                  ContentResult System.Web.Mvc.Controller.Content(string content);

                  我返回 JSON 對象的位置,如

                  System.Web.Script.Serialization.JavaScriptSerializer jsonSerializer= 新 System.Web.Script.Serialization.JavaScriptSerializer();var jsonResponse = jsonSerializer.Serialize(新 { IArticleMediaId = 0, ImageUrl = Url.Content(fullImgPath)});返回內容(jsonResponse);

                  I am returning some json which needs to be handled by javascript as the response to an XMLHTTPRequest.

                  If I set the response's content type to "text/plain", all browsers but Chrome will accept it and pass it to my JS with no problem. However, Chrome will wrap the response in

                  <pre style="word-wrap: break-word; white-space: pre-wrap;"> 
                  

                  before passing it to my javascript.

                  If I set the response's content type to the "proper" "application/json" all browsers but Firefox will accept it and pass it to my JS with no problem. Firefox, however will ask to save or open the response as a file.

                  What's the correct, cross-browser Content-Type?

                  解決方案

                  You may solve the issue by parsing the response into the JSON object by using jQuery funcion parseJSON - http://api.jquery.com/jQuery.parseJSON/

                  The parameter you pass into the function is the JSON object string, which you extract from the response data:

                  function AjaxResponse (data) {  // AJAX post callback 
                    var jsonResult = $.parseJSON(data.substring(data.indexOf("{"), data.lastIndexOf("}") + 1));
                  }
                  

                  Tested (besides Chrome which problem this solves) in FF and IE8 for the following simple JSON result, for other browsers and more complex responses no guarantees...


                  NOTE: the content type in this case is text/plain or text/html I think - I've used the following ASP.Net MVC function to return the result

                  ContentResult System.Web.Mvc.Controller.Content(string content);
                  

                  Where I returned the JSON object like

                  System.Web.Script.Serialization.JavaScriptSerializer jsonSerializer 
                      = new System.Web.Script.Serialization.JavaScriptSerializer();
                  var jsonResponse = jsonSerializer.Serialize(
                      new { IArticleMediaId = 0
                          , ImageUrl = Url.Content(fullImgPath)
                          });
                  return Content(jsonResponse);
                  

                  這篇關于瀏覽器對 json ajax 響應的 Content-Type 標頭有什么要求?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Is it possible for XHR HEAD requests to not follow redirects (301 302)(XHR HEAD 請求是否有可能不遵循重定向 (301 302))
                  NETWORK_ERROR: XMLHttpRequest Exception 101(NETWORK_ERROR:XMLHttpRequest 異常 101)
                  XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分內容)
                  XmlHttpRequest onprogress interval(XmlHttpRequest onprogress 間隔)
                  How can I modify the XMLHttpRequest responsetext received by another function?(如何修改另一個函數接收到的 XMLHttpRequest 響應文本?)
                  What is the difference between XMLHttpRequest, jQuery.ajax, jQuery.post, jQuery.get(XMLHttpRequest、jQuery.ajax、jQuery.post、jQuery.get 有什么區別)

                • <tfoot id='urPve'></tfoot>

                      <legend id='urPve'><style id='urPve'><dir id='urPve'><q id='urPve'></q></dir></style></legend>
                        <tbody id='urPve'></tbody>
                            <bdo id='urPve'></bdo><ul id='urPve'></ul>

                            <small id='urPve'></small><noframes id='urPve'>

                          • <i id='urPve'><tr id='urPve'><dt id='urPve'><q id='urPve'><span id='urPve'><b id='urPve'><form id='urPve'><ins id='urPve'></ins><ul id='urPve'></ul><sub id='urPve'></sub></form><legend id='urPve'></legend><bdo id='urPve'><pre id='urPve'><center id='urPve'></center></pre></bdo></b><th id='urPve'></th></span></q></dt></tr></i><div class="vv75vlz" id='urPve'><tfoot id='urPve'></tfoot><dl id='urPve'><fieldset id='urPve'></fieldset></dl></div>

                            主站蜘蛛池模板: 无菌检查集菌仪,微生物限度仪器-苏州长留仪器百科 | CTP磁天平|小电容测量仪|阴阳极极化_双液系沸点测定仪|dsj电渗实验装置-南京桑力电子设备厂 | 济南拼接屏_山东液晶拼接屏_济南LED显示屏—维康国际官网 | 喷码机,激光喷码打码机,鸡蛋打码机,手持打码机,自动喷码机,一物一码防伪溯源-恒欣瑞达有限公司 | 海尔生物医疗四川代理商,海尔低温冰箱四川销售-成都壹科医疗器械有限公司 | 365文案网_全网创意文案句子素材站| 网站建设,北京网站建设,北京网站建设公司,网站系统开发,北京网站制作公司,响应式网站,做网站公司,海淀做网站,朝阳做网站,昌平做网站,建站公司 | 上海公众号开发-公众号代运营公司-做公众号的公司企业服务商-咏熠软件 | 沈阳庭院景观设计_私家花园_别墅庭院设计_阳台楼顶花园设计施工公司-【沈阳现代时园艺景观工程有限公司】 | 耐高温风管_耐高温软管_食品级软管_吸尘管_钢丝软管_卫生级软管_塑料波纹管-东莞市鑫翔宇软管有限公司 | 扒渣机厂家_扒渣机价格_矿用扒渣机_铣挖机_撬毛台车_襄阳永力通扒渣机公司 | 合肥地磅_合肥数控切割机_安徽地磅厂家_合肥世佳电工设备有限公司 | 杭州厂房降温,车间降温设备,车间通风降温,厂房降温方案,杭州嘉友实业爽风品牌 | 盐水蒸发器,水洗盐设备,冷凝结晶切片机,转鼓切片机,絮凝剂加药系统-无锡瑞司恩机械有限公司 | [官网]叛逆孩子管教_戒网瘾学校_全封闭问题青少年素质教育_新起点青少年特训学校 | 煤机配件厂家_刮板机配件_链轮轴组_河南双志机械设备有限公司 | 自动检重秤-动态称重机-重量分选秤-苏州金钻称重设备系统开发有限公司 | 学考网学历中心| 热风机_工业热风机生产厂家上海冠顶公司提供专业热风机图片价格实惠 | 抓斗式清污机|螺杆式|卷扬式启闭机|底轴驱动钢坝|污水处理闸门-方源水利机械 | 警用|治安|保安|不锈钢岗亭-售货亭价格-垃圾分类亭-移动厕所厂家-苏州灿宇建材 | 双吸泵,双吸泵厂家,OS双吸泵-山东博二泵业有限公司 | 齿式联轴器-弹性联轴器-联轴器厂家-江苏诺兴传动联轴器制造有限公司 | 大通天成企业资质代办_承装修试电力设施许可证_增值电信业务经营许可证_无人机运营合格证_广播电视节目制作许可证 | 济宁工业提升门|济宁电动防火门|济宁快速堆积门-济宁市统一电动门有限公司 | 冷却塔降噪隔音_冷却塔噪声治理_冷却塔噪音处理厂家-广东康明冷却塔降噪厂家 | VOC检测仪-甲醛检测仪-气体报警器-气体检测仪厂家-深恒安科技有限公司 | 上海办公室装修公司_办公室设计_直营办公装修-羚志悦装 | 济南货架定做_仓储货架生产厂_重型货架厂_仓库货架批发_济南启力仓储设备有限公司 | 北京宣传片拍摄_产品宣传片拍摄_宣传片制作公司-现像传媒 | 塑胶跑道_学校塑胶跑道_塑胶球场_运动场材料厂家_中国塑胶跑道十大生产厂家_混合型塑胶跑道_透气型塑胶跑道-广东绿晨体育设施有限公司 | 智能气瓶柜(大型气瓶储存柜)百科| 混合生育酚_醋酸生育酚粉_琥珀酸生育酚-山东新元素生物科技 | 南京兰江泵业有限公司-水解酸化池潜水搅拌机-絮凝反应池搅拌机-好氧区潜水推进器 | 亿诺千企网-企业核心产品贸易 | 耐压仪-高压耐压仪|徐吉电气 | 定做大型恒温循环水浴槽-工业用不锈钢恒温水箱-大容量低温恒温水槽-常州精达仪器 | 贴片电容-贴片电阻-二三极管-国巨|三星|风华贴片电容代理商-深圳伟哲电子 | 郑州巴特熔体泵有限公司专业的熔体泵,熔体齿轮泵与换网器生产厂家 | 儿童语言障碍训练-武汉优佳加感统文化发展有限公司 | 铸铝门厂家,别墅大门庭院大门,别墅铸铝门铜门[十大品牌厂家]军强门业 |