CodeIgniter Forums

Full Version: CSS styling for every blog from database
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]echo sara[/eluser]
Hi,

I have been out of programming for a while. Slowly getting back into it. Right now i have created a small blog where i can submit a title and some body info. Once i click submit it post the info in the fields into the database and on the same page it show the info via ajax. The issue i have is when it submits to the database and shoots out via ajax; all the info (title, body) go into the same div and the div doesn't reproduce. so for every row of title i want a css styling to repeat it self instead now i just have all the rows of title going into the same div.

Code:
<div id="ajaxtitle"> </div>
<div id ="ajaxcomment"> </div>
<div id="titlebody"></div>



this is how i want it
Example:

Title ******** a box which is blue
Body


Title ******** another box which is blue
Body


Title ******** another box which is blue
Body

El Forum

[eluser]Unknown[/eluser]
please use the
Code:
&lt;?php json_encode ?&gt;
function.after that try to use this code for parsing json

Code:
success:function(response){
  //alert(response);
  var obj = jQuery.parseJSON(response);
  $.each(obj,function(index,val){
    var html= '<div id="ajaxtitle"><b>'+val.title+'</b><br/> '+val.ajaxcomment+'</div>';
    $("div[id=titlebody]").append(html);
  });                                      
}