Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery ajax load not a function

This example

<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script> <div id="test"></div> <script> $(document).ready(() => {   $('#test').load('doesntmatter'); }); </script> 

seemed to me like it is identical to the examples for the ajax load function. As the code snippet can tell you, it actually errors out with

Uncaught TypeError: $(...).load is not a function 

What am I doing wrong?

like image 493
Guillaume CR Avatar asked Sep 01 '17 15:09

Guillaume CR


People also ask

Is not a function Ajax?

ajax is not a function" error occurs when loading the slim version of jQuery and trying to use the ajax function. The ajax function is excluded from the slim jQuery version. To solve the error load the regular jQuery version on your page.

How to load function in jQuery?

The jQuery load() method is a simple, but powerful AJAX method. The load() method loads data from a server and puts the returned data into the selected element. Syntax: $(selector).

How do I know if jQuery is loaded?

Basically, the most reliable way to check if jQuery has been loaded is to check typeof jQuery — it will return "function" if jQuery was already loaded on the page, or "undefined" if jQuery hasn't been loaded yet.

Is not defined in jQuery?

You may experience the “jQuery is not defined error” when jQuery is included but not loaded. Make sure that it's loaded by finding the script source and pasting the URL in a new browser or tab. The snippet of text you should look for to find the URL to test.


1 Answers

https://code.jquery.com/jquery-3.2.1.slim.min.js is the slim edition of jquery, which does not include ajax. slim is the default version included in an Express server. Use the full version of jquery at https://code.jquery.com/jquery-3.2.1.min.js

like image 102
Guillaume CR Avatar answered Sep 17 '22 12:09

Guillaume CR