jQuery Load function not loading the file

0 votes

I am trying to use Jquery to load html code into another html file, using Jquery's the .load() method.

I have tried using an absolute path to access the file but I am still getting the same error. I have also tried navigating to absolute path and the file and it will open with no problem in a browser so it dose not appear to be an accesses issue. I have also mapped to the latest version of jQuery instead of my local version.

The error response is unidentified which is making this problem harder to solve:

Updated Code: made changes to code from user recomendations.

Main HTML Page

<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>

    <script type="text/javascript">
        jQuery(document).ready(function(){
            jQuery("#test").load("/menu.html", function(response, status) {

        if(status === 'error') {
            alert("Failed to load menu.html");
        }
        else {
            alert("Success!");
        }    
    });
});
</script> 
</head>

</head>

<body>
    <div id="test"></div> 
</body>
Jun 29 in Web Development by gaurav
• 18,960 points
609 views

1 answer to this question.

0 votes

The jQuery load() method allows HTML or text content to be loaded from a server and added into a DOM element. Syntax: $.
jQuery load() Method

  1. url: request url from which you want to retrieve the content.
  2. data: JSON data to be sent with request to the server.
  3. callback: function to be executed when request succeed
answered Jun 29 by rajatha
• 7,440 points

Related Questions In Web Development

0 votes
0 answers
0 votes
1 answer

Error: Failed to load resource: the server responded with a status of 404 (Not Found)

Your files are not under the JSP folder that's ...READ MORE

answered Dec 16, 2020 in Web Development by Gitika
• 65,890 points
64,109 views
0 votes
0 answers

jQuery(...).iris is not a function

I am trying to implement color picker ...READ MORE

Jul 28 in Web Development by gaurav
• 18,960 points
41 views
0 votes
0 answers

Clear an image preview file that was removed from the array with jquery

I tried to figure this out for ...READ MORE

Aug 2 in Web Development by gaurav
• 18,960 points
44 views
0 votes
1 answer

What is jQuery?

Hey, jQuery is a fast and concise JavaScript ...READ MORE

answered Feb 14, 2020 in JQuery by kartik
• 37,510 points
334 views
0 votes
1 answer

Uncaught TypeError: Cannot read property 'msie' of undefined - jQuery tools

Hello, Use the following script tag in your ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,780 points
9,373 views
0 votes
1 answer

Uncaught Error: Bootstrap's JavaScript requires jQuery

Hello @kartik, You have provided wrong order for ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,780 points
16,593 views
0 votes
1 answer

How to make Bootstrap popover Appear/Disappear on hover instead of click?

Hello @kartik, Set the trigger option of the popover to hover instead ...READ MORE

answered May 12, 2020 in JQuery by Niroj
• 82,780 points
1,440 views
0 votes
1 answer

Loading gif in jQuery ajax call is not showing

Create a div with your image. Make it ...READ MORE

answered Jun 27 in Web Development by rajatha
• 7,440 points
203 views
0 votes
1 answer

jquery - is not a function error

In Wordpress jQuery.noConflict() is called on the jQuery file ...READ MORE

answered Aug 4 in Web Development by rajatha
• 7,440 points
29 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP