Akshay Arora
Akshay Arora

Reputation: 1945

Get contents of a local page into another page

I am trying to get only some specific <div> elements from a page (on my PC, say source.html ) to another page, say index.html. I am using jQuery ajax for the purpose and my index.html has a script like:

$.ajax({url: "source.html", success: function(result){
            $("#div1").html(result);
        }});

I just wrote it to check if I am actually getting anything or not but to my dismay, I get nothing on my page.

I opened the browser console and got the following errors:

Mismatched tag: Expected </meta> : source.html
Mismatched tag: Expected </meta> : index.html

I am not really able to guess what might be the reason for these errors? Is this the right way? Any help? Thanks.

Edit: My HTML starts like the following:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Cuckoo Sandbox</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<style>
Styling here
</style>
</head>

My HTML is very large ( Hence I want to extract only some info), but I am redirected to this last head tag, when I click on the error.

Upvotes: 0

Views: 55

Answers (1)

Ashwani Goyal
Ashwani Goyal

Reputation: 616

Try this:

$("#div1").load("source.html #someDiv");

Make Sure you have jquery.js or jquery.min.js included in your HTML. I don't see it in your HTML snippet

Upvotes: 1

Related Questions