Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript AJAX, Jquery .load problem

ziggelflex

New Coder
Hi, I am new here. I have an issue with AJAX.

I am using safari Version 12.1

This is my code:

HTML:
<!DOCTYPE html>

<html lang="en">
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8">
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="description" content="">
        <meta name="author" content="">
        <meta rel="icon" href="assets/images/favicon.ico">
        <title>Test</title>

        <!-- Custom CSS -->
        <link rel="stylesheet" href="assets/css/style.css">

        <!-- GoogleFonts -->

        <!-- HTML5 shiv and Respond.js IE8 support of HTML5 elements and media queries -->
        <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
        <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
        <![endif]-->

    </head>

    <body>
        <div id="div1"><h2>Let jQuery AJAX Change This Text</h2></div>

        <button>Get External Content</button>


        <!-- Imported JavaScript libraries -->
        <script src="assets/js/jquery-3.6.0.js"></script>
        <script src="assets/js/jquery.fullpage.js"></script>

        <!-- test Javascript files -->
        <!--<script src="assets/js/test.js"></script>-->

        <script>
            $("button").click(function(){
              $("#div1").load("ajaxload.html", function(responseTxt, statusTxt, xhr){
                if(statusTxt == "success")
                  alert("External content loaded successfully!");
                if(statusTxt == "error")
                  alert("Error: " + xhr.status + ": " + xhr.statusText);
              });
            });
        </script>

    </body>

</html>


This is the code for the ajaxload.html page

HTML:
<h1>Portfolio</h1>

<p>Congratulations you have loaded content from an external page</p>

For some reason I keep on getting the Error message...

Can anyone please help me with this.

Thanks

Ziggelflex
 

Buy us a coffee!

Back
Top Bottom