Obviously I need to elaborate. Every single function even ones that can be replaced by vanilla JS, are jQuery functions that work, but the AJAX function does not work.
$.ajax({
type: "POST",
data: {
email: emailInput,
mode: 0
},
url: "main.php",
cache: false
}).done(function(response) {
});
I tried it without promises, I tried it as $.post, I tried everything but it doesn't work.
Obviously I need to elaborate. Every single function even ones that can be replaced by vanilla JS, are jQuery functions that work, but the AJAX function does not work.
$.ajax({
type: "POST",
data: {
email: emailInput,
mode: 0
},
url: "main.php",
cache: false
}).done(function(response) {
});
I tried it without promises, I tried it as $.post, I tried everything but it doesn't work.
Share Improve this question edited May 8, 2017 at 23:05 User9123 the Rebel asked May 8, 2017 at 22:37 User9123 the RebelUser9123 the Rebel 511 gold badge1 silver badge4 bronze badges 21- 3 have you tried debugging the code with the dev tools of your browser? – Isaac Commented May 8, 2017 at 22:40
- 2 Type $ in the browser console. What does it show? – Kevin Collins Commented May 8, 2017 at 22:43
-
try
jQuery.ajax
instead of$.ajax
– Mahesh Singh Chouhan Commented May 8, 2017 at 22:46 -
2
@KevinCollins Typing $ even on about:blank in Chrome (at least) won't be a true test as the inspector provides it's own
$
which acts similar to jQuery. – Phix Commented May 8, 2017 at 22:50 - 1 Yes but that's obviously because of a user error since $.ajax is a well working API. We need to see more of your code. – mariocatch Commented May 8, 2017 at 23:15
2 Answers
Reset to default 6Quite late, but have you regular version of jQuery? Slim version doesn't contain ajax functions among others. Check here
ajax is part of the jQuery
API. In order to use it, you need to make sure jQuery
is included somewhere on your page, above the usage of it. Also, make sure you're calling it after jQuery
has been loaded on the page.
Like this:
<script src="https://code.jquery./jquery-2.2.4.min.js" type="text/javascript"></script>
<script>
$(document).ready(function() {
console.log($.ajax);
});
</script>