[英]My code has a simple issue that i cant figure out
I am setting up a link for my web page to take me to another site. 我正在为我的网页设置一个链接,以将我带到另一个站点。
Ive tried everything i know how to do . 我已经尽了我所能做的一切。 my knowledge is limited though. 我的知识有限。 basically when you visit https://beatsbycayde.com/roster/ it should take you to 基本上,当您访问https://beatsbycayde.com/roster/时,它应该带您
"https://braytech.org/2/{destinyId}/{characterId}/legend"
for some reason it doesnt And I cannot figure out why any help would be greatly appreciated it it instead takes you to 由于某种原因,它并没有。我无法弄清楚为什么任何帮助将不胜感激,它反而带您进入
https://braytech.org/2/{destinyId}/fstats/legend
I know that i have fstats in there iam trying to us it as an object and call it in the href 我知道我在那里有fstats我试图将其作为对象并在href中调用它
// get list of members and populate roster table var roster = []; $.when($.ajax({ url: "https://www.bungie.net/platform/GroupV2/699392/Members/", headers: { "X-API-Key": "47b810e692d64237911c2cbe0d433cfe" } }).success(function(json) { if (json.ErrorStatus === 'Success') { roster = json.Response.results; console.log('Exalted member list:', roster); } else { alert('Uh oh, looks like Bungie\\'s doing server maintenance or having problems. Please check back again soon!'); console.log(json); } }).error(function(json) { alert('Uh oh, looks like Bungie\\'s doing server maintenance or having problems. Please check back again soon!'); console.log(json); }), $.ajax({ url: 'https://www.bungie.net/platform/destiny2/2/profile/4611686018429000034/?components=200', headers: { 'X-API-Key': "47b810e692d64237911c2cbe0d433cfe" } }).success(function(res) { console.log('PS4 stats:', res); })).then(function() { listMembers(roster); }); function listMembers(rsp) { var list = $('.memberList-list'), on = 0, sortMembers = function(method) { // sort by date joined if (method = joined) { list.find('.member').sort(function(a, b) { return ($(b).data('joined')) < ($(a).data('joined')) ? 1 : -1; }).appendTo(list); } else if (method = username) { list.find('.member').sort(function(a, b) { return ($(b).data('username')) < ($(a).data('username')) ? 1 : -1; }).appendTo(list); } list.find('.member.online').prependTo(list); }; for (var i = 0; i < rsp.length; i++) { var profile = rsp[i].bungieNetUserInfo, member = $('<a></a>'); // tally up online members if (rsp[i].isOnline) { on++ } // check for valid profile // some users don't have Bungie profiles somehow and it breaks function if (typeof profile != 'undefined') { // store response data in semantic variables var name = rsp[i].destinyUserInfo.displayName, joinDate = rsp[i].joinDate, joined = joinDate.substring(0, joinDate.indexOf('T')), online = rsp[i].isOnline, icon = profile.iconPath, memberId = profile.membershipId, memberType = rsp[i].destinyUserInfo.membershipType, destinyId = rsp[i].destinyUserInfo.membershipId, rank = rsp[i].memberType; // configure D OM node and add to page $('#destiny-Id').text(destinyId); $.ajax({ url: "https://www.bungie.net/Platform/Destiny/2/Account/" + destinyId + "/", headers: { "X-API-Key": "47b810e692d64237911c2cbe0d433cfe" } }).done(function(json) {}); $(function() { $.ajax({ url: "https://www.bungie.net/Platform/Destiny/2/Account/4611686018429000034/", headers: { "X-API-Key": "47b810e692d64237911c2cbe0d433cfe" }, success: function(data) { // Gambit stats var fstats = data.Response.data.characters[0].characterBase.characterId; // Populate stats // pvp $('#player-f-stats').text(fstats); }, error: function(data) { alert('Uh oh, failed to load player stats! Looks like Bungie\\'s doing server maintenance or having problems. Please check back again soon!'); console.log('Error loading player stats:', data); } }); }); member.attr({ 'class': 'j-row vertical-center-row member', 'href': '/player/?bungieId=' + memberId + '&destinyId=' + destinyId + '&joined=' + joined + '&rank=' + rank, 'title': 'See player profile for ' + name, 'data-joined': joined.replace(/-/g, ''), 'data-username': name, 'data-online': 'false', 'data-searchable': name, }).html('<div class="j-col j-col-1 member-icon"><img src="https://bungie.net/' + icon + '"></div>' + '<div class="j-col j-col-3 member-name"><h3>' + name + '</h3></div>' + '<div class="j-col j-col-3 member-joined" data-label="Joined">' + joined.replace(/-/g, '/') + '</div>' + '<div class="j-col j-col-3 member-status" data-label="Status"><span class="member-online" id="status-' + memberId + '">' + online + '</span></div>' + '<div class="j-col j-col-3 member-button"><a class="button outline gold full-width">' + 'View Stats' + '</a></div>' + '<div class="j-col j-col-3 member-button"> + <a href="https://braytech.org/2/' + destinyId + '/' + "fstats" + '/legend">In Depth Stats</a>' + '</a></div>').appendTo(list); // indicate online/offline status if (String(online) === 'true') { $('#status-' + memberId).text('Online').addClass('online').closest('.member').attr('data-online', true).addClass('online'); } else { $('#status-' + memberId).text('Offline').removeClass('online'); } sortMembers(joined); // sort members by join date } } }
You have nested links. 您有嵌套的链接。 That breaks your HTML and prevents the href
you want to be used. 这会破坏您的HTML并阻止您要使用的href
。
Here you create the wrapper of each member. 在这里,您将创建每个成员的包装。 Which is a link. 这是一个链接。
member.attr({
'class': 'j-row vertical-center-row member',
'href': '/player/?bungieId=' + memberId + '&destinyId=' + destinyId + '&joined=' + joined + '&rank=' + rank,
...
And then you append another link inside of it here: 然后在其中附加另一个链接:
... <a href="https://braytech.org/2/' + destinyId + '/' + "fstats" + '/legend">In Depth Stats</a>' ...
So I would suggest that you change the structure of your member
element. 因此,我建议您更改member
元素的结构。 Maybe place the top link in the position of the View Stats button
and change that button to a <a>
tag. 也许将顶部链接放在“ View Stats button
的位置,然后将该View Stats button
更改为<a>
标签。 But then as a consensus the whole member
element won't be clickable, only the links. 但是,作为共识,整个member
元素将不可单击,而只能单击链接。
Good luck! 祝好运!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.