代码工作正常,但在setinverval ajax更新后,Accordion无效。
$(document).ready(function () {
function LoadXML() {
$.ajax({
crossOrigin: true,
type: 'GET',
url: 'Reuters.xml',
dataType: 'xml',
success: function (xml) {
var htmlstring = '';
$(xml).find('item').each(function () {
htmlstring += '<h3>' + $(this).find('title').text() + '</h3><div>' + $(this).find('description').text() + '</div>';
});
$('#accordianmenu').html(htmlstring).accordion();
}
});
}
LoadXML();
setInterval(function () {
LoadXML() // this will run after every 5 seconds
}, 5000)
});