如何通过 JSON 请求 HTML 文件

How to request a HTML file via JSON?

本文关键字:HTML 文件 请求 JSON 何通过      更新时间:2023-09-26

我尝试获取一些文件,但其中一种格式是应该嵌入iFrame的HTML。对于此请求,我使用 AJAX 和 JSON 作为数据。有谁知道如何调用HTML文件?现在它正在调用 SWF 文件。

if ( 'undefined' === typeof(fsStructure[strPath]) ) {
        $.ajax({
            'url'       : '../php/navigator.php',
            'dataType'  : 'json',
            'data'      : {'tarFolder':strPath},
            success : function( respObj, textStatus, jqXHR ) {
                if ( 'undefined' !== typeof(respObj['status']) ) {
                    if ( 
                            ('success' === respObj['status']) && 
                            ('undefined' !== typeof(respObj['subfolders'])) && 
                            ('undefined' !== typeof(respObj['subswfs'])) ) {
                        processNewDFData( respObj, $currentSelectItem, strPath );
                    } else {
                        alert( conf.messages.bad_response_format );
                    }
                } else {
                    alert( conf.messages.bad_response_format );
                }
            },
            error : function( jqXHR, textStatus, errorThrown ) {
                alert( conf.messages.failed_ajax_request );
            }
        });
    }

您可以使用 jquery get 请求获取 html 文件。

$.get('/yourfile.html', function (data) {
   console.log(data);
});