我的Javascript代码出错
Error in my Javascript code
每当我运行代码时,我都会收到错误,如果有人能解释出了什么问题或给我看一个修复的版本?我将非常感谢
混合内容:
位于'的页面https://www.roblox.com/catalog/'是通过HTTPS加载的,但请求了一个不安全的XMLHttpRequest端点'http://c3.rbxcdn.com/4b192cd410398472f25d7aea541a352c"。此请求已被阻止;必须通过HTTPS提供内容。
代码:
var globeid = 0
var priceUnder = 5000
function check(z){
$.get(z, function(data){
if ($(data).find('#ctl00_cphRoblox_LimitedEditionRemaining').length) {
var check = $(data).find('#BuyWithRobux').children('div').data()
var Token = data.match(/Roblox.XsrfToken.setToken([^)]+)/)[1].match(/[^(']+/)[0]
if (check['expectedPrice'] <= priceUnder) {
$.post('https://www.roblox.com/api/item.ashx?rqtype=purchase&productID=' + check["productId"] + '&expectedCurrency=1&expectedPrice=' + check["expectedPrice"] + '&expectedSellerID=1')
console.log('Purchased: ' + check["itemName"] + " | " + check["itemId"] + " for " + check["expectedPrice"])
}
}
})
}
function checkifnewlim() {
$.get("https://www.roblox.com/asset/?id=261522650").success(function(r) {
r = decodeURIComponent(r);
r = JSON.parse(r.substring(r.indexOf("{"), r.lastIndexOf("}") + 1));
var notifications = r
for (var info in notifications) {
var currid = notifications[info]["id"]
if (currid > globeid) {
console.log("NEW ITEM...")
globeid = currid
notificationpopup(notifications[info])
var nn = notifications[info]
var url = nn.url.split('&')[0]
check(url)
}
}
})
function notificationpopup(n) {
var notification = new Notification(n.lite, {
icon: n.icon,
body: n.header + "'n" + "Price: " + n.items.Price + "'n'n" + "Autobuy: OFF"
});
var url = n.url.split('&')[0]
notification.onclick = function() {
console.log("NOTIFICATION SUCCESS!");
window.open(url);
}
}
}
setInterval(function() {
checkifnewlim()
}, 100)
如果你的代码在HTTPS页面上运行,你只能从其他域请求HTTPS内容,任何试图与HTTP资源对话的xhr请求都将被浏览器阻止。如果您试图访问的内容在您的域中,请确保它是通过HTTPS提供的。否则你可以做两件事之一:
- 如果你有一些服务器端代码在运行,你可以尝试添加一个钩子来代理你的调用
- 人们试图通过使用像这里这样的第三方库来解决这个问题,这对你来说隐藏了复杂性
相关文章:
- 我在代码点火器中出错
- 将javascript代码转换为jquery代码时出错
- 我的Javascript代码出错
- 在Tomcat中运行Javascript代码时出错
- 不允许的关键字符.通过 Codeigniter 中的 jQuery 在帧中加载嵌入代码时出错
- 运行Javascript继承代码时出错
- 将js代码转换为jQueryMobile时出错
- 将Flask中的变量显示为javascript代码时出错
- 代码在shell中运行,但提供'可以't查找变量'从文件运行时出错
- 我的代码出错
- 如何将鼠标悬停在链接上时显示demo_test.txt的内容?我哪里出错了,我的代码应该是什么样子
- 使用 qunit 测试我的代码时出错
- 使用 Lodash 合并数组,为什么结果是重复的数组值?,我的代码在哪里出错
- 语法加载具有现代化 JavaScript 代码的 html 页面时出错
- 从 JavaScript 函数调用 C# 方法背后的代码时出错
- Ajax 客户端框架运行 HTML 代码时出错
- HTML代码编辑器出错
- 读取'时出错;无法读取属性'x'未定义的'在HTML5 Canvas代码中
- 为什么这个依赖于HTML5地理位置的javascript代码出错
- 使用Google Maps API和分析云代码时定义地理编码器变量时出错