Donnie Ashok Donnie Ashok - 4 months ago 78
Javascript Question

Uncaught TypeError: $.post is not a function : Error in Chrome

I am getting this error in Chrome Console:


Uncaught TypeError: $.post is not a function


for this piece of code:



<script type="text/javascript">
$('#cl_submit').click(function() { //#cl_submit is a button
$('#cl_stage1msg').html('Processing...');
$.post("process/cookie.php", $("#cl").serialize(), function(response) { //#cl is a form
$('#cl_stage1msg').html(response);
});
return false;
});
</script> <!-- popup included -->


I just couldn't find anything wrong in this. Why is this not working, any clues?

However,
$('#cl_stage1msg').html('Processing...');
is working fine.

Seems like only the post function is not getting recognised.

I am using https://code.jquery.com/jquery-3.1.0.slim.min.js

Answer

You are using the slim version of jQuery, which doesn't have AJAX(in your case the $.post() function).

Use this one:

https://code.jquery.com/jquery-3.1.0.min.js