weixin_33704591 2018-07-11 17:31 采纳率: 0%
浏览 9

Angular的AJAX更新

I am trying to implement a polling method in my client that uses AJAX. I am building an ASP.NET framework Web application, wit c# on the backend and I use JavaScript with Angular on the front end, but I am unsure of....

1.) If the code I have will actually do real time updates and update the displayed content on my web page like intended.

2.) If the way I am incorporating Angular into my AJAX request will work.

and 3.) If I need to specify 'get' in the body of the ajax request, like type: 'get';

I have a variable attached to $scope called instruments that I would like to update with the data from the url, and update my webpage if there are any changed to the data. Obviously the url will contain the actual URL where I wish to get data from. Here is my code thus far in my module...

var updates = function update() {
    $.ajax({
        url: '...',
        success: function (data) {
            $scope.instruments = data;
        },
        complete: function () {
            setTimeout(update, 5000);
        }
    });
};
  • 写回答

1条回答 默认 最新

  • weixin_33709590 2019-08-29 09:02
    关注

    its easy with v_comet packge

    import { V_ } from 'v_comet';
    
    /**
       title is the variable that need to change.
    */
    
    V_('this.state.title', object); /** in react */
    
    V_('this.title', object); /** in angular */
    

    more details: https://www.npmjs.com/package/v_comet

    评论

报告相同问题?