Hey there guys,
First time posting so please forgive any bad conduct. 😛
I am trying to display search results from an AJAX request on a new page by looping over expressionengine tags and injecting the entry_id param as a JS variable.
This seems to work when hardcoding the entry_id, but as soon as adding the variable there is no result.
Please view code below. Any help would really go a long way at this point!
Many thanks!
$.getJSON( "/searchResults.json", function( properties ) {
for (i = 0; i < properties.length; i++) {
var id = properties[i].propertyId;
var html = "{exp:channel:entries channel='properties' search:property_id='" + id + "'} {title}{/exp:channel:entries}";
$(".titles").append(html);
};
});
Oh right! I see where you’re coming from. Thanks so much.
Do you have any ideas on what the best method to parse entries out that contain a key received from an API json array?
I am attempting to build a search bar that takes a number of parameters (date, location, price, etc) needed for the call and then returns results in a new page.
Going around in circles here.
Right now, I have a form that saves the form vaules in a session storage variable, navigates to a new page, assembles the variables into a url and then runs an ajax request for the json.
The json then returns the key of entries that meet the requirements.
Any help would be much much appreciated.
Your best bet is probably to do create an AJAX endpoint where the backend code delivers a result set ready for use in the frontend without needing to go back to the server again. Deliver the results from the endpoint in JSON format and then loop through the results in JS. A bit like what you’ve done now, but you’ll need to do additional processing in the backend code so the result set can be looped through in the JS without additional AJAX calls.
Your best bet is probably to do create an AJAX endpoint where the backend code delivers a result set ready for use in the frontend without needing to go back to the server again. Deliver the results from the endpoint in JSON format and then loop through the results in JS. A bit like what you’ve done now, but you’ll need to do additional processing in the backend code so the result set can be looped through in the JS without additional AJAX calls.
Way over my head, but will do some research. Thanks so much for the help!
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.