[英]api not loading in ajax method but loading in script tag
I am trying to load the api through ajax
method.. but when I load it in ajax method its not loading... 我正在尝试通过
ajax
方法加载api ..但是,当我以ajax方法加载它时,它无法加载...
if i load it like this 如果我这样加载
<script src="https://mail.google.com/mail/u/0/#inbox"></script>
its loading 它的负载
providing my code below.. 在下面提供我的代码。
var bvapiUrl = window.location.protocol + 'https://mail.google.com/mail/u/0/#inbox';
window.loadBazaarvoiceApi = function (callback) {
if (window.$BV) {
callback();
} else {
$.ajax({
url: bvapiUrl,
cache: true,
dataType: 'script',
success: function () {
$($BV.docReady);
callback();
}
});
}
};
$BV.ui("rr", "show_reviews", {
productId: "test1"
});
HTML:: HTML ::
<div id="BVRRContainer">
<!-- include contents of {DisplayCode}/reviews/product/1/001122.htm if it exists -->
</div>
You are doing this: window.location.protocol + 'https://mail.google.com/mail/u/0/#inbox';
您正在执行以下操作:
window.location.protocol + 'https://mail.google.com/mail/u/0/#inbox';
: window.location.protocol + 'https://mail.google.com/mail/u/0/#inbox';
, so the output is not a valid url because you are adding http or https depending on the protocol, twice. ,因此输出不是有效的网址,因为您两次根据协议添加http或https。
See: https://mail.google.com/mail/u/0/#inbox
请参阅:
https://mail.google.com/mail/u/0/#inbox
: https://mail.google.com/mail/u/0/#inbox
You have to remove the protocol part of your api url. 您必须删除api URL的协议部分。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.