0

I am unable to get this piece of code working. I am running this on xampp. The alert works fine but the html wont load. Please help.

I have added the links to jquery 3.2.1

index.html

$(document).ready(function(){
$("#buttonClick").click(function(){
    alert("Hello");
    $("#viable").load('new_123.html');
});
});
</script>

New_123.html

<html>
<body>
<h1>Hello 123</h1>
</body
</html>
7
  • where is the DOM with viable id Commented Nov 4, 2017 at 5:21
  • 1
    Do you get any errors in the brower's console? If you check the Browser's Dev Tools Network tab do you see the expected HTML being returned? Commented Nov 4, 2017 at 5:22
  • please add appropriate code for the used elements Commented Nov 4, 2017 at 5:22
  • I am unable to see any html element with id buttonClick? so how it will work.it will not work Commented Nov 4, 2017 at 5:28
  • You shouldn't have <html> and <body> tags in the HTML that you're loading, since that should already be in the current page. Commented Nov 4, 2017 at 5:32

2 Answers 2

4

Your body tag is missing a closing bracket ">".

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

3 Comments

It need to be a comment . And it seems TYPO mistake not the actual cause of problme. So the answer is not useful at all.
Interesting, im new to stackoverflow and now starting to understand the culture behind it... will keep on contributing selectively and carefully
There's nothing wrong with posting this as an answer if you think it will solve the OP's problem. But if you just wanted to point out an incidental issue not related to the main problem then it should be posted as a comment instead.
0

I have used the same code and i mgetting the result properly May be that '>' is an issue!

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <script src="jquery-3.2.1.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
        $("#buttonClick").click(function(){
           var d= $("#viable").load('b.html');
        });
    });
    </script>
</head>
<body>
    <div id="viable"></div>
    <button id="buttonClick"></button>
</body>
</html>

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.