문제

I have a complicated page being rendered by PHP and would like to keep all elements of the page up to date via AJAX long polling. Is there some kind of general / clever way to design an infrastructure to support this without having to specify manually each element to update? Just looking for ideas. Thanks!

도움이 되었습니까?

해결책

Using jQuery, I would send a comma-separated list of jQuery selectors to update to the server. The server will ultimately respond by reading those selectors and producing the HTML to fill up the elements matching the selectors:

$.get("/updater", { elementsToUpdate: "#someDiv,#someTable,#someOtherElement"}, function(json) {
      $.each(json, function(k, v) {

        // the key is the selector, the value is the 
        // HTML to set to that (or those) element(s):
        $(k).html(v);
      });    
}, "json"); // we are expecting the server to return JSON

The server will respond by sending JSON to the client with the following structure:

 {"#someDiv":"this is some HTML to fill up div with ID someDiv","#someOtherElement":"here is some more HTML","#someTable":"here is some more HTML"}

다른 팁

maybe add a special class to all the elements to be updated via ajax, and also you can encode extra data in some other attributes for example

<a class="ajaxUpdate" data="{'a':'json or whatever', 'put whatever here':'ok'}">test</a>

then with jquery you can easily pull out that data and eval it, and use it in your ajax

웹 파트 페이지를 사용하고 SharePoint Designer를 통해 사용자 정의 할 수 있지만 설계 관리자를 통한 페이지의 고급 사용자 정의가 불행히도 SharePoint 2013 Foundation에서 사용할 수 없습니다.

Keep your pages elements structure as private data and have the public elements to update them

var page = (function(){
    var private_data = {
    //json
    };

    return {
        workOnData : function(){//process the data}

    }
})()

This is good way you can keep your pages data safe and smooth.

귀하의 질문에 따라 두 가지 클래스를 만들었고 라는 것을 알 수 있습니다.

  1. version.class
  2. open.class

    어디에서 "Titlescreen"클래스를 얻고 있습니까?

    Version.class에서만 주요 메서드가 있습니다. 따라서 Version.class의 Main () 메서드는 엔트리 포인트 일 수 있습니다.

    다음과 같이 프로그램을 실행할 수 있습니다.

    Java 버전 Titlescreen

    Titlescreen은이 프로그램의 입력이 될 수 있습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top