I am trying to fill a form with some preset values. The user chooses from a list of presets. This calls an ajax function which wil fill the form on success.
I thought everything works fine until someone told me it wouldnt work for him. So i tried it on my own devices and came to the conclusion there has to be something wrong with the .html() when I am trying to get HTML data inside a node.
This is the code:
$.ajax({
type: "GET",
url: "something.php",
dataType: "xml",
cache: false,
success: function(xml){
var title = $(xml).find('title').text();
$('#event-title').val(title);
var description = $(xml).find('description');
alert(description.html());
},
error: function() {
alert("An error occurred while processing XML file.");
}
});
xml var could look like this:
<?xml version="1.0"?>
<preset>
<title>This is a title</title>
<description><p>This is a paragraph</p><p>This is another paragraph</p></description>
</preset>
While the "title" is filled out correctly the "description" will return nothing. Everything after this line of code won't be executed as well.
I tried to get the content without using .html(), something like using .children() or .first(), but wasn't able to get the content from there without stripping the HTML-tags from it.