Jump to content

Check out our Community Blogs

Register and join over 40,000 other developers!

Recent Status Updates

View All Updates

- - - - -

JQuery, json, ajax, html transfer, programming practice

ajax json jquery

  • Please log in to reply
1 reply to this topic

#1 ferovac


    CC Resident

  • Just Joined
  • PipPipPipPip
  • 83 posts

Posted 17 May 2011 - 04:23 AM

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


<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
  • 0

#2 ferovac


    CC Resident

  • Just Joined
  • PipPipPipPip
  • 83 posts

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
  • 0

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download