Hi,

I've managed to finish my first plugin and re-learn javascript at the same
time. So I'm not quite sure if this is a Javascript or jQuery issue.

The plugin loads external content from HTML or XML data using an AJAX call
to the file name generated from the LI element clicked.
DEMO: http://www.sozzi.cn/jquery/fish.fn.trial3.html

It works perfectly for the HTML variant but the XML fails in IE throwing a "
Object doesn't support this property or method" error.
It seems to happen in the XML call and parse function on the line finding
the "link" within the XML object:

(snip)...
$.get(XMLurl, function(xml){
                        $("site", xml).each(function(){          // step 
through each 'site' xml
node
                        $(this).find("link").each(function(){ // find 'link' 
insidet the  'site'
node and turn it into html
                                settings.parsedXML += "<div class='link'> 
"+$(this).text()+" ";
....(snip)

Any thoughts on what I'm doing wrong?



js:
/*
 * AZlinker 0.4 Beta
 * By Angelo Sozzi (http://www.sozzi.cn/jQuery)
 * A jQuery plugin that will load XML or HTML links into divs
 * by maping the UL>LI element names to filenames 
 * Demo at http://www.sozzi.cn/jQuery/a_zlink.html
 */

$.fn.AZlinker = function(settings) {
     var settings = $.extend({
        targetID: "#xml_here",
                elemname: "li",
                methodXML: true,
                parsedXML: ""
     }, settings || {}); // overwrite settings if there are any given in the
function call
  // other plugin code
  $("#busy").hide();
  var list = $(this).find(settings.elemname)
  list.hover(
                function(){ $(this).next().addClass("medium");
                                $(this).prev().addClass("medium");
                                $(this).addClass("large");},
                function(){ $(this).next().removeClass("medium");
                                $(this).prev().removeClass("medium");
                                $(this).removeClass("large");}
                        );
        // make clicked li active, read html and use to retrieve html or xml
                list.click(function(){        //Add an OnClick event to all <li>
                list.removeClass("active");   //OnClick Remove the active class 
from all
li  
                $(this).addClass("active"); //Add class=active to clicked li
                if (settings.methodXML){
                        var XMLurl = "xml/"+$.trim($(this).text())+".xml";  
//Read out text from
litext li and make filename from it
                        loadXML(XMLurl);
                        }
                else {
                HTMLurl = "html/"+$.trim($(this).text())+".html"; //read out 
text from
litext li and make filename from it
                $(settings.targetID).load(HTMLurl);             //trim is used 
because text leaves a
space in IE
                        }
                });     
// Helper funtions 
// The Ajax XML call and parsing to html
        function loadXML(XMLurl){
                settings.parsedXML="";
                        $.get(XMLurl, function(xml){
                        $("site", xml).each(function(){          // step 
through each 'site' xml
node
                        $(this).find("link").each(function(){ // find 'link' 
insidet the  'site'
node and turn it into html
                                settings.parsedXML += "<div class='link'> 
"+$(this).text()+" ";
                                }).end().find("description").each(function(){
                                settings.parsedXML += $(this).text()+ " </div>";
                                });     
                        $(settings.targetID).html(settings.parsedXML);
                        });
                });
        };
        // don't break the chain
        return this;
  }; // end jQuery plugin
-- 
View this message in context: 
http://www.nabble.com/IE-XML-parsing-problem-tf2469241.html#a6884561
Sent from the JQuery mailing list archive at Nabble.com.


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to