skip to Main Content

I have the following code:

<div class=“phpversion”></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>

<script>
            $(document).ready(function() {
                $.ajax({
                    url:"/core/components/seo/templates/default/functions/generic/php-version.php",
                    success:function(result){
$( "div.phpversion” ).html(result);
                    }
                });             
            });
</script>

The aim is to fill in the div with class phpversion with the result obtained.

When I use “alert(result);” instead of “$( “div.phpversion” ).html(result);”, the popup box with the expected value displays on load of the page.

Can you please help 🙂 ?

2

Answers


  1. Use ID for that div and update the JavaScript code accordingly:

    <div id="phpversion"></div>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
    
    <script>
                $(document).ready(function() {
                    $.ajax({
                 url:"/core/components/seo/templates/default/functions/generic/php-version.php",
                        success:function(result){
    $( "#phpversion" ).text(result);
                        }
                    });             
                });
    </script>
    Login or Signup to reply.
  2. It’s because you’re using wrong double-quote symbol. You’re using the “ symbol instead of ” symbol (3 times in your snippet)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search