2009/02/23

jquery ajax with xml

1. How to generate XML output By default, echo in php sending the text to the browser. So it you try to generate xml output, you have to send the header before xml output to tell teh browser it is xml, like below: header("Content-Type: text/xml; charset=UTF-8"); $smarty->display('cart/popin.tpl'); 2. How to add html code in a xml node To have html in a xml node, you have to use CDATA:

A CDATA section starts with "<![CDATA[" and ends with "]]>":

3. how to use jquery to get XML respond $.ajax({ url: $(this).attr('href'), type: 'GET', dataType: 'xml', timeout: 1000, error: function(){ alert('Error loading XML document'); }, success: function(xml){ // do something with xml //alert('what\'s next'); $('#buynow-result').html($(xml).find('pop').text()); $('#buynow-inform').show('slow'); }

No comments:

Post a Comment