Uploading HTML content through Javascript causes my <title> tag in some cases

This is only a problem with the explorer, and the symptoms are:

I have links that when clicked will load into HTML chunks (none of which contain html header tags) using javascript. The html nodes are placed in different <div> around the page, possibly 3 different places with three different pieces that were added through javascript.

When these pieces are loaded into the <title> page, it is set to <title></title> for some unknown (to me) reason. I used the IE developer toolbar to confirm this by checking the DOM tree.

I have other pages that do similar things, but it doesn't seem to be a problem.

Edit: Further validation seems to show that swfObject has something to do with it. One of the pieces that I bring in has SWF, which is included by swfObject. If I turn off the swfObject call, the page will no longer be blocked.

Edit: code:

 /** * getContentItemById() * @itemId = string * @contentType = string */ function getContentItemById(itemId, contentType, subType) { $j.ajax({ type: "GET", cache: false, url: "/gallery/", data: "contentType=" + contentType + "&itemId=" + itemId + "&slice=itemView" + "&subType=" + subType, dataType: "html", beforeSend: function (XMLHttpRequest) { $j("#viewer").fadeOut(); }, success: function(html){ $j("#viewer").html(html).fadeIn(); if (itemId && contentType) { var state = {}; state["itemId"] = itemId; $j.bbq.pushState(state, 0); } }, error:function (xhr, ajaxOptions, thrownError){ //alert("Error code: " + xhr.statusText); } }); 
+4
source share
1 answer

Since you are using jQuery , you can try .load() , which is a simpler method for what you are trying to achieve.

 function getContentItemById(itemId, contentType, subType) { var data = "contentType=" + contentType + "&itemId=" + itemId + "&slice=itemView" + "&subType=" + subType; $('#viewer').load('/gallery/ #'+itemId, data, function() { //oncomplete function if (itemId && contentType) { var state = {}; state["itemId"] = itemId; $j.bbq.pushState(state, 0); }); } 

Refer to the API documentation to understand how .load() http://api.jquery.com/load/ works .load()

0
source

Source: https://habr.com/ru/post/1307065/


All Articles