Jquery load () doesn't work at all in IE8

Google is full of this question, but none of the other pages help me.

I tried to change jquery versions, tried to execute all var $ j = jQuery.noConflict (); tried reordering JS / jquery scripts, tried the caching suggested by jQuery, but still my load () t works.

<a onclick="loadCont('canyou.php');">Can you help us</a> function loadCont(file){ $j("#maincont").load(file); alert(file); return false; } 

As always, it loads in any browser other than IE8. Alart () exists for debugging IE8, and the file is successfully transferred, it simply is not loaded into #maincont

Any help regarding code or answers is appreciated. Thanks

+6
source share
3 answers

Try setting it a little differently. Use the following code and see if you have any results.

HTML

 <!-- link with ajax target in href --> <a class="loadlink" href="canyou.php">Can you help us</a> 

JQuery

 <html> <head><title>can you</title></head> <body> <!-- we only want to load content from this div --> <div id="content">This is the only content we want returned...</div> </body> </html> 

EDIT

If canyou.php contains a complete html skeleton with <html> and <body> tags, then you should have jQuery to parse only the HTML code you want from this page and drop the rest (you don't want to drag <html> or <body> in your #maincont div). You can use jQuery by adding a space, then a selector after the URL parameter in the load () method. Here is an example HTML:

 <html> <head><title>can you</title></head> <body> <div id="content"> This is the only content we want returned... </div> </body> </html> 

The new download call will look like this:

 $('#maincont').load($(this).attr('href') + ' #content'); // Only get the content in #content div 
+1
source

letter j between $ and (. is it normal?

it is not $("#maincont").load(file);

I use load with IE8 ... it works well personally

0
source

Yo Bro. You forgot e.preventDefault ();

If you want to open a link in a div on your current page , for example:

<a class="loadlink" href="canyou.php">Can you help us</a>

Your jQuery should look like this:

 $("a.loadlink").click(function(e){ e.preventDefault(); //this prevents the redirect that the <a> tag makes on default // then enter the rest of your jQuery here: var file = $(this).attr("href"); $("#maincont").load(file); }); 

This should work "plug-n-play".

0
source

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


All Articles