提要:

$.get("异步文件",数值,回调函数);

加载XML文档

a.xml

<?xml version="1.0" encoding="UTF-8"?>
<booklist>
    <book isbn='b001'>
        <name>java</name>
        <author>Gaosilin</author>
    </book>
    <book isbn='b002'>
        <name>Python</name>
        <author>卡卡</author>
    </book>
</booklist>

$.get()方法

    $(document).ready(function()
    {
        $('a').click(function()
        {
            
            $.get('a.xml',function(data){

                $(data).find('book').each(function()
                {
                    $('#isbn').html($(this).attr('isbn'));
                })
            })

            return false;
        })
    })

 该该函数是简写的 Ajax 函数,相当于:

$(document).ready(function()
    {
        $('a').click(function()
        {
            $.ajax(
            {
                url:'a.xml',
                success:function(data){
                    $(data).find('book').each(function()
                    {
                        $('#isbn').html($(this).attr('isbn'));
                    })
                }
            })
        })
    })

 

 

相关文章:

  • 2022-02-22
  • 2021-07-29
  • 2022-02-19
猜你喜欢
  • 2022-12-23
  • 2021-05-31
  • 2021-12-01
  • 2021-05-25
  • 2021-06-29
  • 2021-06-21
  • 2021-08-08
相关资源
相似解决方案