0

I'd like to use .load to add a button, that exists on another page, for each cell on a website.

Let's say it looks like this:

Lalalala
Videooooo Here
Wop wop Wop wop

and all of those would be links. Then if you go to each link, for example "Lalalala", you'd go to a page looking like this:

Info here, blabla. Lala

So, I tried to use:

$(".mainpart").append("Magnet: <div id='magneturl'>Loading download buttons..</div>");
$("#magneturl").load("zoo-s01e04-hdtv-x264-lol-ettv-t10975316.html");

And it loads fine; enter image description here

But if I use:

$(".mainpart").append("Magnet: <div id='magneturl'>Loading download buttons..</div>");
$("#magneturl").load("zoo-s01e04-hdtv-x264-lol-ettv-t10975316.html .magnetlinkButton");

It will just print Magnet:

I hope I make any kind of sense with this post.

3
  • Could you copy your returned html in pastebin or something? Commented Jul 22, 2015 at 13:05
  • @BishopBarber dpaste.com/0VCX98Y Commented Jul 22, 2015 at 13:07
  • are you sure you have elements with that class? it seems to work find for me: jsfiddle.net/u8xtycw7/1 Commented Jul 22, 2015 at 13:40

2 Answers 2

4

The line

$("#magneturl").load("zoo-s01e04-hdtv-x264-lol-ettv-t10975316.html .magnetlinkButton");

is trying to fetch the content of the page and filter it applying the jQuery selector .magnetlinkButton. Judging by the image you posted, the file you are loading is not an HTML page but a JSON; or maybe it is HTML, but it doesn't have any element with class="magnetlinkButton".

If you are actually trying to read the property .magnetlinkButton from that JSON text, I'd suggest looking into .getJSON() instead.

Sign up to request clarification or add additional context in comments.

Comments

-1

check your jquery version. here is the working example :

<!doctype html>
  <html lang="en">
<head>
    <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
    <b>Projects List:</b>
    <ol id="new-projects"></ol>
    <script>
        $( "#new-projects" ).load( "/resources/load.html #projects li" );
    </script>
</body>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.