开发者

Appending node[index] in XML with jQuery

开发者 https://www.devze.com 2023-04-06 18:54 出处:网络
How I got here: I let my last question on pretty much this same subject gather dust. So, I thought I\'d take what I learned and ask a more precise question.

How I got here:

I let my last question on pretty much this same subject gather dust. So, I thought I'd take what I learned and ask a more precise question.

I've got some information in an XML file that I would like to write to various DIVs on my web page, and something isn't going right.

And the last answer I receiv开发者_开发问答ed definitely behaves in jsfiddle:

http://jsfiddle.net/CK6rD/

But implementing the same code completely fails on my server. I'm not sure if it's the AJAX call, or the XML file, or something with permissions, or browser dependent flaws with Chromium. I'm completely stumped.

What I'm working with:

$(document).ready(function(){
    $('#header').click(function(){
        $('p#test').html('At least <em>this</em> works');    
        $.ajax({
            type: "GET",
            url: "archives.xml",
            datatype: "xml",
            success: function(xml){
             xmlDoc = $.parseXML( xml ),
             $xml = $( xmlDoc ),
             $title = $xml.find( "title" );
             $("div#viewer").append( $title.eq(0).text() );
            }
        });
    });
});

What I'm asking:

Where should I be looking for my problem if the script doesn't throw an error with Try/Catch and the dev tools in Chromium say everything looks okay too?

As far as I can tell, I have no output from the success function, but how can I test that to be sure?


For posterity, the problem was in the AJAX options. The URL must go before the type. At least, that's how my AJAX calls are successfully formed in jQuery these days:

$.ajax({
    url: "archives.xml",
    type: "GET",
    datatype: "xml",
    success: function(xml){}
});
0

精彩评论

暂无评论...
验证码 换一张
取 消