So this would probably be question on how to implement something into my website .
The words in the the title would sum up my question.
I am using ajax to get results on a search, the search results are being transfer via json object
for example :
{
title: "ebook"
author: "john doe"
}
now i can echo that result in a dive element i have prepared for the search results
eg.
<div id="results"> </div>
so by echoing i would get :
<div id="results">ebook john doe</div>
now i want to add some html around "ebook" and "jhon doe"
note: that html would be the same for all the results
So how do i transfer that html to the user , whats the best practice of doing such a thing ???
I have in mind sending lika a templet on page load and storing it in a variable in javascript
and then just inserting data into that templet and echoing the templet
1 reply to this topic
#1
Posted 17 May 2011 - 04:23 AM
|
|
|
#2
Posted 21 May 2011 - 06:53 AM
HM ....
Ok so how i did it ... is I made a javascript function with all the html needed to display results, and then when i would get the results as a json object throu ajax, all i would do is past the data to that function and it would fill in all the data into the html, and i would then write that html where i needed it on the page
so basiclly, html is hardcoded in javascript, and the data is transfered via ajax connection as a JSON object
Ok so how i did it ... is I made a javascript function with all the html needed to display results, and then when i would get the results as a json object throu ajax, all i would do is past the data to that function and it would fill in all the data into the html, and i would then write that html where i needed it on the page
so basiclly, html is hardcoded in javascript, and the data is transfered via ajax connection as a JSON object
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









