简体   繁体   中英

How to reload the html page without refreshing the total page?

我想重新加载div但不刷新,我已经尝试在Jquery中使用.load()

Ajax with Jquery

    $.ajax({url: "http://www.mywebsite.com/getResults", success: function(result){
        //update your div with result here
    }});

Try this

   function callThisFn(id)
   {    
     var p_url= 'a.html'
     jQuery.ajax({
     type: "GET",             
     url: p_url,
     success: function(data) {
       $('#summary').html(data);

    }
 });    
}

summary is the id of your div where you want to display html content.

In angular context, if you want to refresh one page, use $route.reload() inside page's controller. It will safely refresh single page without losing context data of angular environment.

Sample Code:

 var app = angular.module('myApp', []); app.controller('myCtrl', function($scope, $route) { $scope.firstName = "John"; $scope.lastName = "Doe"; $route.reload(); }); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM