0

i would like to load a div from a page in my page with jquery

Here is a Jsfiddle but it doesn't work, what is wrong in my code ?

In my example I'm using

$('.namebook1origin').load($('http://www.booclin.ovh/tom/last/update.html #namebook1'));

but in my page I'm using

$('.namebook1origin').load($('update.html #namebook1'));



Here is a live example

$('.namebook1origin').load($('http://www.booclin.ovh/tom/last/update.html #namebook1'));
$('.namebook2origin').load($('http://www.booclin.ovh/tom/last/update.html #namebook2'));
$('.namebook3origin').load($('http://www.booclin.ovh/tom/last/update.html #namebook3'));
$('.namebook4origin').load($('http://www.booclin.ovh/tom/last/update.html #namebook4'));
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span class="namebook1origin">.</span><br/>
    
<span class="namebook2origin">.</span><br/>
    
<span class="namebook3origin">.</span><br/> 
    
<span class="namebook4origin">.</span><br/>
clodo0683
  • 89
  • 2
  • 3
  • 10
  • 1
    Is `www.booclin.ovh` your website? If not you will get CORS issue, Additionally you need to pass URL to `load` method `$('.namebook4origin').load('https://www.booclin.ovh/tom/last/update.html #namebook4')` – Satpal Nov 03 '16 at 12:23
  • Don't wrap your URL and selector in `$()`. – George Nov 03 '16 at 12:24
  • yes in my example i added the full link but i use this one in my page load($('update.html #namebook1')); – clodo0683 Nov 03 '16 at 12:24

2 Answers2

2

load accepts a string as input not a jquery object, unram the $() from the string

$('.namebook1origin').load('http://www.booclin.ovh/tom/last/update.html #namebook1');
$('.namebook2origin').load('http://www.booclin.ovh/tom/last/update.html #namebook2');
$('.namebook3origin').load('http://www.booclin.ovh/tom/last/update.html #namebook3');
$('.namebook4origin').load('http://www.booclin.ovh/tom/last/update.html #namebook4');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span class="namebook1origin">.</span><br/>
    
<span class="namebook2origin">.</span><br/>
    
<span class="namebook3origin">.</span><br/> 
    
<span class="namebook4origin">.</span><br/>

The snippet doesn't work because of CORS

Community
  • 1
  • 1
madalinivascu
  • 32,064
  • 4
  • 39
  • 55
0

JQuery's .load() should be like this: $(selector).load("internalDomainURL #div",callback);

$("#namebook1origin").load("http://www.booclin.ovh/tom/last/update.html #namebook1");

Mamdouh Saeed
  • 2,302
  • 1
  • 9
  • 11