Example call using jQuery for predictive search is not working

Highlighted
Explorer
88 7 21

In this article

https://shopify.dev/docs/themes/ajax-api/reference/predictive-search

there is an example of a JQuery call

jQuery.getJSON("/search/suggest.json", {
  "q": "jacket",
  "resources": {
    "type": "product",
    "limit": 4,
    "options": {
      "unavailable_products": "last",
      "fields": "title,product_type,variants.title"
    }
  }
}).done(function(response) {
  var productSuggestions = response.resources.results.products;

  if (productSuggestions.length > 0) {
    var firstProductSuggestion = productSuggestions[0];

    alert("The title of the first product suggestion is: " + firstProductSuggestion.title);
  }
});

If I put this in between script tags <script> and </script>, right above the closing body tag </body>, nothing happens when I open the page. I should get an alert?

I cheked if JQuery is implemented with the following code

    if (window.jQuery) {  
        // jQuery is loaded  
        alert("Yeah!");
    } else {
        // jQuery is not loaded
        alert("Doesn't Work");
    }

I get the Yeah alert. 

My website is menschenskinder-shop.de and the password vuffey

I use the minimal theme.

I'd be very happy about help here. Thank you!! 

0 Likes
Highlighted
Explorer
88 7 21

Please delete this post, wrong topic, it's not a feedback, sorry!

0 Likes