繁体   English   中英

来自jQuery.get()或jQuery.ajax()的访问响应

[英]Access response from jQuery.get() or jQuery.ajax()

我使用$.get()从文件获得响应

$.get('filename.svg', function (response) {
    console.log(response);

    return response;
});

当我记录响应时,我看到这样的内容

#document
    <svg ...>
        <g>....</g>
    </svg>

我想问一下如何访问#document 属性。 并在没有#document情况下打印<svg></svg>标签

为了弄清楚我到底需要什么。 我需要使用getBBox()计算SVG大小

您可以使用$.ajax()并提供dataType作为text

$(function(){
    $.ajax({
        url: 'filename.svg',
        dataType: 'text'
    }).then(function (response) {
        console.log(response);
    });
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM