I get a
ReferenceError: ajax is not defined
error in browser console when I try to make an ajax call.
I'm pretty sure I properly loaded the jQuery library, therefore I don't understand how can the $.ajax function not be defined.
Here is the HTML (without irrelevent css and markup):
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="js/script.js"></script>
</head>
<body>
<div>
<a class="getUsersA">Get users</a>
<div id="gridD"></div>
</div>
</body>
</html>
Here is the script.js file:
$(document).ready(function() {
$(".getUsersA").click(function() {
$.ajax({
url:ajax/getUsers.php,
type:POST,
data:({
id:0
}),
success:function(results) {
$("#gridD").html(results);
}
});
});
});
Thank you for any help!
You need to wrap ajax/getUsers.php, in quotes. or else it would look for a local variable ajax rather than treating it as a string.
url: "ajax/getUsers.php",
Something like this:
$.ajax({
url: 'ajax/getUsers.php',
type: 'POST',
data:({
id: 0
}),
success:function(results) {
$("#gridD").html(results);
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With