English 中文(简体)
含有 X酸value的 X
原标题:Containing an XML nodevalue with jQuery

My Predicament:

我的服务器上有一些东西,我想与美加新军的呼吁联系起来:

  • a XML 档案

  • a 超文本测试指数

  • a 全套超文本

  • 某些 j

XML拥有超文本的相对地址。 jery本应 gr灭这一价值,而我的一些DIVs则在测试指数页上。 归根结底,指数网页应更新其某些超文本,而无需全负荷再载,就像我所研究的美军一样。

不幸的是,我几乎不知道我做什么。

这是我所努力的:

$(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){
                $( div#viewer ).append($(this).find( title )).text();
            }
        });
    });
});

我的日本宇宙航空研究开发机构打电话doesn t do any。 我可以告诉我,我做的是错事,但此时我很高兴地勾销了DOM 4的错误和未预料到的Token Errors。

这里的试验XML I m试图打电话和浏览数据:

<archives>
    <entry>
        <date>
            <year>2011</year>
            <month>April</month>
            <day>1</day>
        </date>
        <title>Trees!</title>
        <deck>and something that definitely isn t a tree</deck>
        <source>./copy/1april2011.html</source>
    </entry>
</archives>

What I already know:

  • 我知道javascript能够进入当地档案系统。 所有这些问题都是一米进入网上的问题。

  • j Qu Qu select select select 至少是我从过去5年或6年那里从各种博客中收集的。

  • I know about JSON, but I m having a hard time translating from XML to JSON. The whole braces and brackets syntax is a bit confusing.

Questions:

  • What s wrong with my success function? It mimics tutorials I ve read, but I ve clearly got something wrong.

  • 一旦我掌握了XML的价值,我就能够以一种能够发挥<<<>外>功能”的方式,将这一价值包含在一个变量中。 AJAX呼声能够阅读吗?

最佳回答

jquery selectors a are not meant for parsing the xml wrapping the xml in jquery object and parsing it that way is browser dependent use .parseXML instead

here is a demo http://jsfiddle.net/AKJwF/3/

$(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" ).text();
                $( div#viewer ).append($title);
            }
        });
    });
});
问题回答

暂无回答




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签