久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<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="qwawimqqmiuu" 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="qwawimqqmiuu" 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="qwawimqqmiuu" id='urPve'><tfoot id='urPve'></tfoot><dl id='urPve'><fieldset id='urPve'></fieldset></dl></div>

                            主站蜘蛛池模板: 国产在线精品一区二区 | 免费黄色av网站 | 精品一区二区三区日本 | 欧美精品一区二区免费视频 | 91精品一区二区三区久久久久久 | 久久一级大片 | 久久久久国产精品午夜一区 | 精品欧美乱码久久久久久1区2区 | 国产精品国产亚洲精品看不卡15 | 日本五月婷婷 | 一级片免费视频 | 亚洲国产一区二区三区, | 不卡的av在线 | 精品视频亚洲 | 精品久久精品 | 国产九九精品 | 亚洲精品久久久一区二区三区 | 91视频电影| 成人一级黄色毛片 | 少妇性l交大片免费一 | 日韩视频 中文字幕 | 中文字幕在线播放第一页 | 中文字幕国产精品 | 国产亚洲精品美女久久久久久久久久 | 91亚洲精品国偷拍自产在线观看 | 成年人精品视频 | 久久国产精品无码网站 | 久久亚洲一区 | 日本二区 | 欧美美女爱爱视频 | 中文字幕免费 | 一区二区三区免费在线观看 | 91麻豆产精品久久久久久夏晴子 | 亚洲播放一区 | 国产精品久久久久久久久久不蜜臀 | www.9191.com| 国产高清视频在线观看 | 久久精品视频播放 | 国产精品中文字幕在线 | 久久久久久久一区二区 | 91免费在线视频 |