Leonidas Dosas
asked on
Refresh div via ajax without lost ccs <li> styles
I refresh a div with <li> element inside via the following code :
$('.trash').click(function (){
var id=$(this).attr("data-id");
console.log(id);
$.ajax({
url: 'includes/ajax_chart.php',
type: 'POST',
data: {id:id},
success: function (data) {
$('#refresh').load('includes/widjet.php');
console.log("success");
}
});
//$('#refresh').load('includes/widjet.php');
});
The div refresh normally but I am loosing the css of the <li> elements inside the div. How i can retrieve or fix this problem?
You shouldn't lose any CSS, is it possible that the html returned from your Ajax request has a different hamlet structure causing the CSS rules to not apply. Seeing the original html and the html returned from the Ajax request will also help debug this.
ASKER
I use Ajax to delete a chat post and then I use the
Before:
After using the script function:
$('#refresh').load('includto refill the div panel chat. Due the load function works good (the panel chat contains the update posts) for some reason I lost the <li> css style.When i refresh the page then the chat panel looks as I expect with the set css styles. I don't have return data from the ajax function so to set these in my div elements. The following images show the problem:es/widjet. php');
Before:
After using the script function:
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok my friend I find the solution.The problem was that the id=#refresh it must be in the <ul> and not in the <div>.I tried and it works.So when the jQuery load it starts from ul. Your methodology was great and it helps me a lot. Many many thanks
Glad I could help