2

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.

2 Answers2

6

Quite late, but have you regular version of jQuery? Slim version doesn't contain ajax functions among others. Check here

Jan Zahradník
  • 2,417
  • 2
  • 33
  • 44
0

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.com/jquery-2.2.4.min.js" type="text/javascript"></script>
  <script>
    $(document).ready(function() {
      console.log($.ajax);
    });
  </script>
mariocatch
  • 8,305
  • 8
  • 50
  • 71
  • 1
    Read the first part of my comment **I don't know why it says it's not a function when every single function is a jQuery function other than getElementById and my own functions. But somehow ajax doesn't work.** – User9123 the Rebel May 08 '17 at 22:55
  • 1
    See my edit. Also, post your entire HTML in a fiddle so we can help you out more. – mariocatch May 08 '17 at 22:59