How can I access search.json on an external page?

How can I access search.json on an external page?

ibrahimnsall
Shopify Partner
2 0 0

I need to access this page from an external site, but I'm having trouble.

 

https://recycle-appliances.com/search.json?q=severin

 

This is my code: 

$.ajax({
url: 'https://recycle-appliances.com/search.json?q=severin',
type: "GET",
crossDomain: true,
contentType: "application/json; charset=utf-8",
dataType: "jsonp",
success: function (data) {
console.log(data);
}
});

 

This is the error:

Uncaught SyntaxError: Unexpected token '<' (at search.json?q=severin&callback=jQuery1124049738821019783397_1677420328616&_=1677420328617:1:1)

 

How can i fix this, i need help guys.

Reply 1 (1)

Jason
Shopify Partner
11207 226 2319

Where are you seeing search.json as being a valid AJAX endpoint? That is likely part of the problem - you're calling a storefront endpoint that doesn't exist.  That store has the password page enabled so makes sense that a call to it's content would fail but that won't be the primary issue here.

 

Are you building a headless site? If so, pulling data from that kind of url doesn't make as much sense. The storefront api has a "products" query like:

 

products(first: 10, query: "search term") {
...

^ truncated for simplicity.

★ I jump on these forums in my free time to help and share some insights. Not looking to be hired, and not looking for work. http://freakdesign.com.au ★