{"id":2456,"date":"2019-06-25T14:12:31","date_gmt":"2019-06-25T13:12:31","guid":{"rendered":"http:\/\/www.dpscomputing.com\/blog\/?p=2456"},"modified":"2021-03-01T21:47:43","modified_gmt":"2021-03-01T21:47:43","slug":"ajax-is-not-a-function","status":"publish","type":"post","link":"https:\/\/www.dpscomputing.com\/blog\/2019\/06\/25\/ajax-is-not-a-function\/","title":{"rendered":"$.ajax is not a function"},"content":{"rendered":"\n<pre class=\"wp-block-verse\">TL;DR; Make sure you've <a href=\"https:\/\/www.w3schools.com\/jquery\/jquery_get_started.asp\">loaded jQuery<\/a> into your page.<\/pre>\n\n\n\n<p>You&#8217;re ripping your hair out.  &#8220;Why won&#8217;t it work?&#8221;.  You&#8217;ve already subsituted that infernal cURL request that didn&#8217;t work and now ajax isn&#8217;t working!<\/p>\n\n\n\n<p>Don&#8217;t panic &#8211; the $.ajax(&#8230;) is not a function error is more common than you might think.  <\/p>\n\n\n\n<p>And thankfully the solution is usually pretty quick.  <\/p>\n\n\n\n<p>Have you stopped and checked that you&#8217;ve loaded jQuery onto your page?<\/p>\n\n\n\n<pre class=\"wp-block-verse\">Pro tip: remember to use the minified version on live sites.  <\/pre>\n\n\n\n<p>You can host it on your server:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;head&gt;\n&lt;script src=\"jquery-3.4.1.min.js\"&gt;&lt;\/script&gt;\n&lt;\/head&gt;<\/code><\/pre>\n\n\n\n<p>Or you can use your favourite CDN for super performance.  <\/p>\n\n\n\n<p>Google CDN:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;head&gt;\n&lt;script src=\"https:\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/3.4.1\/jquery.min.js\"&gt;&lt;\/script&gt;\n&lt;\/head&gt;<\/code><\/pre>\n\n\n\n<p>Microsoft CDN:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;head&gt;\n&lt;script src=\"https:\/\/ajax.aspnetcdn.com\/ajax\/jQuery\/jquery-3.4.1.min.js\"&gt;&lt;\/script&gt;\n&lt;\/head&gt;<\/code><\/pre>\n\n\n\n<p>Chill out, job done :).  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>TL;DR; Make sure you&#8217;ve loaded jQuery into your page. You&#8217;re ripping your hair out. &#8220;Why won&#8217;t it work?&#8221;. You&#8217;ve already subsituted that infernal cURL request that didn&#8217;t work and now ajax isn&#8217;t working! Don&#8217;t&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[2139],"tags":[2141,2140,2143,2144],"class_list":["post-2456","post","type-post","status-publish","format-standard","hentry","category-development-issues","tag-ajax","tag-ajax-is-not-a-function","tag-code-issues","tag-development-issue"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3nsfA-DC","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/posts\/2456","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/comments?post=2456"}],"version-history":[{"count":2,"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/posts\/2456\/revisions"}],"predecessor-version":[{"id":3072,"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/posts\/2456\/revisions\/3072"}],"wp:attachment":[{"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/media?parent=2456"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/categories?post=2456"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/tags?post=2456"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}