Search page returning results in JSON format


(Mahearnpad) #1

Matrix Version: 5.3.2.1

I’ve set up my type formats to return a result inside a JSON object. My results page then wraps these inside an array.

I can get the JSON resutls when I query the search page directly, using “./?queries_keyword_query=term1+term2” etc.

But when I send an xhr request to the search page asset, I get the whole HTML page (with the JSON string inside it).

Is there any way to just get the just the JSON results back, in the data returned by the XHR object?

Michael


(jtris) #2

Hey mate, have you applied a blank design/layout to the search page and viewed the source of the results page (to check for any lingering Squiz div code)?

If so and it still brings in design code, check the settings to be extra sure there are no design/layouts being called via URL or some other condition.

Finally, I usually configure a site’s settings/layouts screen to use a blank design/layout combo in new User Defined settings. Once set up, add these values to your request object, where XXXX is the user defined code you used:

SQ_DESIGN_NAME: XXXX,
SQ_PAINT_LAYOUT_NAME: XXXX

You can also set up a new design code for JSON too:

<MySource_PRINT id_name="__global__" var="content_type" content_type="application/json" />
<MySource_AREA id_name="page_body" design_area="body" />

(Mahearnpad) #3

Yes, thanks for the reminder. I forgot to apply the design file for the JSON mime type.

Got it working now!
thanks