使用jsonp获取doctype错误

时间:2016-02-08 10:17:14

标签: jquery html ajax html5 jsonp

我正在调用使用ajax在最后添加安全参数的limelight服务器。

Limelight网址假设返回html(这是预期的。)

现在的问题是当我在Ajax中解雇limelight url时会抛出错误 -

SyntaxError: syntax error <!DOCTYPE html>

现在我无法避免数据类型:jsonp,因为它在crossdomain调用中是必需的,我也无法避免输出,它恰好是html5源。

简化 -
1)limelight url - http://cdnllnw.xxxxx.com/somefolder/index.html?securityparameter = somehashvalue 2)上面的url在fiddler中返回html并在浏览器中呈现html(在地址栏中使用时)
3)当在ajax中使用上面的url时 -

$.ajax({
    url: lmlightLink,
    type: 'GET',
    crossDomain:true,
    dataType : 'jsonp',
    mimeType: "text/html",
    async:false,
    success: function (response) {
        console.log(response);
    },
    error: function (response) {
        console.info(response);
    }
});

4)它抛出以下错误 -

SyntaxError: syntax error <!DOCTYPE html>

我在SO中经历了多个链接,但没有一个建议使用jsonp和html5响应的完美解决方案

任何建议?

限制:请注意,我无法控制响应,因此无法修改从hitlight返回的任何内容。

编辑:

请注意我无法更改dataType ='html'或其他任何内容,因为它必须是'jsonp'否则会引发以下错误 -

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource

0 个答案:

没有答案
相关问题