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, 2022 in Web Development by gaurav
• 23,260 points
3,820 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, 2022 by rajatha
• 7,680 points

Related Questions In Web Development

0 votes
0 answers

how can i get the url of the content( home.html) in adress bar by jquery load() function?

I am using jquery load() function to ...READ MORE

Jul 28, 2022 in Web Development by gaurav
• 23,260 points
602 views
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,770 points
88,011 views
0 votes
0 answers

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

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

Jul 28, 2022 in Web Development by gaurav
• 23,260 points
646 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, 2022 in Web Development by gaurav
• 23,260 points
888 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,520 points
1,315 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,840 points
15,710 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,840 points
23,295 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,840 points
3,311 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, 2022 in Web Development by rajatha
• 7,680 points
1,713 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, 2022 in Web Development by rajatha
• 7,680 points
717 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