JS . load method does not work

Asked

Viewed 150 times

-1

Hi, I made this code to test, because it doesn’t work

<script>
$(document).ready(function(){
    $("#button").click(function(){
        $("#div").load('teste.php');
    });
});
</script>

<input type="button" id="button" name="button" value="ADD PAGE">
<div id="div" name="div"></div>

php test.

<?php>
echo 'teste';
?>
  • Ctrl+Shift+J in the browser, reload the page and see if an error appears.

  • @Rafaelmafra Volta teste:14 Uncaught ReferenceError: $ is not defined&#xA; at teste (teste:14)&#xA; at HTMLInputElement.onclick (teste:19)

  • The code seems correct to me. See if you imported jquery correctly in the page head

1 answer

1

The problem is that I didn’t call Jquery.

I just added this line:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script> 
  • If this second line is not your script, it is unnecessary.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.