显示使用AJAX获取的数据时出现问题 [英] Problem when displaying data fetched with AJAX

查看:74
本文介绍了显示使用AJAX获取的数据时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在< td>内我根据用户按下的链接(足以使我的页面向下滚动)通过AJAX显示大量的照片问题是在另一个页面中我链接到这些照片,链接问题已解决,初始页面通过AJAX获取正确照片,但如果特定的照片是在页面下方,我希望浏览器集中在那里尝试使用锚点(这不起作用,因为它没有找到它和.focus() - 这只适用于文本字段而不是隐藏正如我希望的那样),任何想法?

inside a <td> I display lots of fotos through AJAX according to what link the user pressed (enough to make my page scroll down) the problem is that in another page I have links to these photos the linkage problem was solved and the initiall page fetches through AJAX the correct photos but if the particular photo is way down the page I want the browser to focus there tried with anchor (which do not works since it doesn''t find it and with .focus()-which only works for textfield and not with hidden as I hoped to), any ideas?

推荐答案

你可以尝试在img之后检索图像的''像素位置''(计算样式)渲染并使用scrollTo()方法...但我只是想知道为什么锚解决方案不起作用?你是怎么试过的?


亲切的问候
you could try to retrieve the ''pixel-position'' (computed style) of the image after the img was rendered and use the scrollTo() method ... but i just wonder why the anchor-solution was not working? how have you tried that?

kind regards


我首先在空白的< td>中显示页面。然后调用用正确的照片填充它的函数,所以我猜对于通过AJAX检索的锚点
I first diplay the page with empty the <td> and then call the function which populates it with the right photos so I guess will not work for an anchor retrieved through AJAX


,当页面完全加载并且你要检索的元素是渲染到dom-tree然后你应该能够检索文档中的presnet节点...这意味着你甚至可以在加载任何图像等之前添加锚点但是你应该调用应该滚动页面的方法后!当你想使用dom-methods来检索任何节点时,所有图像和相关的dom节点都被完全加载。


亲切的问候
when the page is fully loaded and the elements that you want to retrieve are rendered to the dom-tree then you should be able to retrieve any node that is presnet in the document ... that means you could even add the anchor before loading any images etc. but you just should call the method that should scroll the page after! all images and relevant dom-nodes are fully loaded when you want to use dom-methods to retrieve any nodes.

kind regards


这篇关于显示使用AJAX获取的数据时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆