Jquery.load () do not embed data in ie8 and below

I have been looking for a solution all day, but I still see this error.

This is an Expression Engine installation for our client, and we want to implement ajax navigation. To do this, we use the $ .load () function by default, and this works fine in ie9, FF, Safari, Chrome, Opera ... but it does not work in ie8 and below.

I checked the callback function that one called IS, the data is sent, I can read it in the console when registering. But for some odd reason, the data is not inserted.

Here is the code:

load_page: function(url, func){ $('#content').load(url+' #content>div', function(data, textStatus, jqXHR){ console.log('page loaded!'); }); } 

There was a whole bunch of extra code in the callback function, but I cleared all javascript / css all. In search of errors, but nothing was found.

Based on the comments, I decided to add the url and download:

Another piece of the puzzle: There is something strange in javascript. Even google maps api do not work properly, which is the first time this has happened to me when using google maps.

EDIT: Answer

I finally found the answer to this question thanks to @epascarello. This is actually the fault of the data I tried to import. Since IE8 and below do not understand HTML5, they will try to import elements into dom, but when warning data I saw the following: [object HTMLUnknownElement], [object HTMLUnknownElement], [object HTMLUnknownElement], ...

When I changed the data layout to use the good old div instead of the article elements, everything worked fine!

+4
source share
5 answers

I had the same problem, and I noticed that if the url returns invalid HTML (for example, an additional end tag), it can stop it from loading or find the correct element.

In my example, all I needed to do was the correct HTML from the URL, and then it worked correctly.

+3
source

Ajax requests are cached in IE8, so just magic

$. ajaxSettings.cache = false;

before using the download function

http://zacster.blogspot.in/2008/10/jquery-ie7-load-url-problem.html

http://api.jquery.com/jQuery.ajax/

cache (default: true, false for dataType 'script' and 'jsonp')
Type: logical
If set to false, this will cause the requested pages not to be cached by the browser. Note. Setting the cache to false will only work with HEAD and GET requests. It works by adding "_ = {timestamp}" to the GET parameters. The parameter is not needed for other types of requests, with the exception of IE8, when a POST is created with a URL that has already been requested by GET.

+2
source

The only thing I see with this code is the lack of a closing bracket

 load_page: function(url, func){ $('#content').load(url+' #content>div', function(data, textStatus, jqXHR){ console.log('page loaded!'); } // <-- this one }); 
+1
source

$.load() works in IE8. I assume that you have a previous JS error, caused only in IE8-, which prevents it from functioning normally or is generally called.

0
source

The problem is that some functions are supported in one, and not in others. For example, one of my personal hatreds is how the inner text is only supported in ie7.8, but not fox or chrome. Here is a compatibility chart if you're interested in http://www.quirksmode.org/dom/w3c_html.html .

On the bottom line, if you do not plan to change the plugin yourself, and you already tried the modernizer, and this did not help, you will have to use a different data loading method. My suggestion is to use .html, you cannot go wrong, or add and manually generate html yourself in js. Simplification is the best solution.

-1
source

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


All Articles