在$ .get请求中运行时,代码日志记录未定义,但在页面上运行时,它可以正常工作吗?

时间:2014-09-20 17:04:13

标签: javascript jquery

我的代码在运行时记录未定义,但是当我在当前页面上运行时(删除$.get请求和$(f)

这是我的代码:

var product = 20219291;
function check(id) {
    $.get('http://m.roblox.com/items/'+id+'/privatesales').success(function(r) {
        var d = r.replace(/img/gi,"flip");
        var f = $(d).find(".ui-btn-text a").first().attr('href');
        console.log(f);
        var s = link.substring(0, link.indexOf('&expectedPrice'));
        var userAssetId = s.replace('/Catalog/VerifyTransfer?userAssetOptionId=', '')
        var price = link.substring(link.indexOf("&expectedPrice=") + "&expectedPrice=".length);
        console.log(userAssetId, price);
    });
}
check(161211433);

1 个答案:

答案 0 :(得分:0)

当您通过浏览器访问此页面时,您已登录,因此存在活动会话。

当您尝试使用ajax访问该页面时,返回的html是我认为此页面的内容:  https://m.roblox.com/Login?ReturnUrl=%2fitems%2f161211433%2fprivatesales

如果您需要登录才能访问某些内容,我建议您使用服务器端的api:

http://wiki.roblox.com/index.php?title=User-created_web_APIs