POST를 사용하여 mySQL에서 데이터를 검색하는 페이지가 있습니다. 그러나 스크롤을 내려 POST를하는 무언가를 클릭하면 끝까지 페이지가 다시 움직이기 때문에 짜증이납니다. 누구든지이 문제를 해결할 수있는 몇 가지 javascript/jquery 플러그인을 알고 있습니까?POST에서 스크롤 사용 안 함
0
A
답변
1
Jumping Inside Pages을 사용해 보셨습니까?
또 다른 예를 How To Link to a Specific Spot on a Page<div id="whatever-you-want-to-call-it">
The content of your div here.
</div>
및 URL은 그 시점
http://www.pagename.html#whatever-you-want-to-call-it
3
글쎄, 당신이 할 경우 AJAX POST에 도착하고, AJAX에서 어떤 결과가있는 페이지의 내용을 대체하는 POST,이 스크롤 효과는 문제가되지 않습니다.
이 작업은 사용자가 원활하게 수행 할 수 있습니다 (브라우저를로드하지 않음).
의이 폼이 있다고 가정 해 봅시다 :
<form id="some_form" action="myphp.php">
<input name="something" value="foo"/>
<input name="something_else" value="bar" />
</form>
및 jQuery를 :
$("#some_form").submit(function() {
var url = $(this).attr("action");
var form_data = $(this).serialize();
// post the same data via an AJAX call
$.post(url, form_data, function(data) {
// replace the contents from the received response
$("html").html(data);
});
// disable the default form submit behavior
return false;
});
0
그것은 e.preventDefault를 사용하는 것이 더 명확를(); jQuery (Uku Loskit이 제안한 것과 같다). 그의 코드에 실수가 있습니다 (작동하지 않을 것입니다). 그래서 수정했습니다.
<form id="some_form" action="myphp.php"">
<input name="something" value="foo"/>
<input name="something_else" value="bar" />
</form>
및 jQuery를 : 여기에
그의 변화에 코드 그런데$("#some_form").submit(function(e) { // e = event object, it has many usefull properties and methods
e.preventDefault();
var url = $(this).attr("action");
var form_data = $(this).serialize();
// post the same data via an AJAX call
$.post(url, form_data, function(data) {
// replace the contents from the received response
$(document).html(data);
});
});
, 당신이 숙박 할 경우 자바 스크립트없이 그것을 달성하는 방법을 방법이 없습니다 같은 페이지 (재로드하지 말고 URL을 변경하지 마십시오). 페이지 매김과 같이 사용하는 경우 url 뒤에 # some-id를 추가 한 다음 페이지가로드 될 때 상단에 있어야하는 항목에 'some-id'ID를 추가 할 수 있습니다. 이것은 잘 작동 할 것이고 js는 필요하지 않습니다. scrollTop
를 사용
0
시도 :
$("#some_form").submit(function() {
var url = $(this).attr("action");
var form_data = $(this).serialize();
var currentScrollTop = $('body').scrollTop();
// post the data via an AJAX call
$.post(url, form_data, function(data) {
// replace the contents from the received response
$(document).html(data);
$('body').scrollTop(currentScrollTop);
});
// disable the default form submit behavior
return false;
});
관련 문제
- 1. iframe에서 스크롤 사용 안 함
- 2. SlickGrid에서 스크롤 사용 안 함
- 3. System.Console.Write로 스크롤 사용 안 함
- 4. MDI의 스크롤 막대 사용 안 함
- 5. 플래시의 화살표 키로 스크롤 사용 안 함
- 6. JavaScript로 가로 스크롤 사용 안 함
- 7. UIScrollView 가로 스크롤 - 왼쪽 스크롤 사용 안 함
- 8. 스크롤 위치에 따라 조건부로 사용/사용 안 함 버튼
- 9. IntelliJ 경고 사용 안 함
- 10. UIPickerView 사용 안 함
- 11. 알림 사용/사용 안 함
- 12. 스크롤보기에서 UIButton 사용 안 함
- 13. JQuery를 사용하여 자동 센터링 사용 안 함 스크롤 가능
- 14. 자바 스크립트없이 조건부로 스크롤 막대 사용 안 함
- 15. GWT : 파이어 폭스의 마우스 가운데 버튼 스크롤 사용 안 함
- 16. 웹 페이지에서 Ctrl + 마우스 스크롤 사용 안 함
- 17. 스크롤 기능이 활성화 된 TextBox에서 에디션 사용 안 함
- 18. WebKit에서 스크롤 막대 사용 안 함 (플랫 프레임 모드)
- 19. flowplayer에서 화살표 키 사용 안 함
- 20. UIWebView에서 하이퍼 링크 사용 안 함
- 21. StyleCop 규칙 사용 안 함
- 22. Zend_Form_Element_Multicheckbox에서 이스케이프 사용 안 함
- 23. 모든 XML보기 사용 안 함
- 24. as3로드시 buttonmode 사용 안 함
- 25. MvcSiteMapProvider 캐싱 사용 안 함
- 26. android에서 마이크 사용 안 함
- 27. Vim에서 ':'문자 사용 안 함
- 28. 디버깅 출력 사용 안 함
- 29. C# 사용 안 함 경고
- 30. cmake에서 테스트 사용 안 함
가 .. 그 일의 동적 인 방법을 더 찾고 있었다 그렇지 않으면 내가 그 서버에서로드되고있는 모든 단일 목록 항목에이를 구현해야 할 것이다 .. – Zakman411
@ Zakman411 : 목록을 렌더링 할 때 동적으로 앵커를 만듭니다. – hakre